home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / gus / gusdk210.zip / ULTRADOC.TXT < prev   
Text File  |  1993-12-17  |  256KB  |  7,128 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.                  UltraSound Software Development Kit (SDK)
  18.                                Revision 2.10
  19.  
  20.                             December 24th, 1993
  21.  
  22.  
  23.  
  24.  
  25.  
  26.                                Documentation
  27.  
  28.  
  29.  
  30.  
  31.  
  32.                                     by
  33.  
  34.                                Kurt Kennett
  35.  
  36.                                     and
  37.  
  38.                                Mike Travers
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.                               Advanced Gravis
  48.                          101-3750 North Fraser Way
  49.                      Burnaby, British Columbia V5J 5E9
  50.                             FAX (604)-431-5155
  51.  
  52.                             Forte Technologies
  53.                           1555 East Henrietta Rd.
  54.                            Rochester, N.Y. 14526
  55.                             FAX (716)-292-6353
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                   NOTICE
  64.  
  65.  
  66. The information contained in  this manual is believed  to be correct.   The
  67. manual is  subject  to change  without  notice  and does  not  represent  a
  68. commitment on the part of FORTE, Advanced Gravis, or Ingenuity Software.
  69.  
  70. Neither FORTE, Advanced Gravis, nor Ingenuity  Software make a warranty  of
  71. any kind with regard to this  material, including, but not limited to,  the
  72. implied warranties of merchantability and fitness for a particular purpose.
  73. Neither FORTE, Advanced Gravis, nor Ingenuity Software shall be liable  for
  74. errors contained  herein  or for  incidental  or consequential  damages  in
  75. connection with the furnishing, performance or use of this material.
  76.  
  77. This document  contains  proprietary  information  which  is  protected  by
  78. copyright.    This manual  is Copyright  (C) 1992,1993  by FORTE,  Advanced
  79. Gravis, and Ingenuity Software.   All rights are reserved.  No part of this
  80. document may be reproduced, transmitted, transcribed, stored in a retrieval
  81. system, or translated into any human  or computer language, in any form  or
  82. by any means; electronic,  mechanical, magnetic, optical, chemical,  manual
  83. or otherwise, without the expressed  written permission of FORTE,  Advanced
  84. Gravis, and Ingenuity Software.
  85.  
  86. Any copying, duplication, selling, or otherwise distributing the program or
  87. support files described in this manual, other than for the limited purposes
  88. of system  backup and  loading the  program into  the computer  as part  of
  89. executing the program, is a violation of the software license agreement and
  90. the law.  Willful violation of the  copyright law of the United States  can
  91. result in statutory damages of up to $50,000 in addition to actual damages,
  92. plus   criminal penalties  of imprisonment  for  up to  one year  and/or  a
  93. $10,000 fine.
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.                              TABLE OF CONTENTS
  101.  
  102.  
  103. Section                                                               Page
  104.  
  105. Chapter 1 - General Information                                          3
  106. 1.0  Introduction                                                        3
  107. 1.1  Features of the UltraSound                                          3
  108. 1.2  Benefits of supporting the UltraSound                               4
  109. 1.3  The GF1 - 32 Voice Sound Synthesizer                                4
  110. 1.4  MIDI Interface                                                      7
  111. 1.5  Joystick Interface                                                  7
  112.  
  113.  
  114. Chapter 2 - Hardware Information                                         8
  115. 2.1  I/O Port Map                                                        8
  116. 2.2  MIDI Control Port                                                   9
  117. 2.3  MIDI Status Port                                                    9
  118. 2.4  MIDI Data Port                                                      9
  119. 2.5  Page Register                                                      10
  120. 2.6  Select Register                                                    10
  121.   2.6.1  Global Registers                                               10
  122.     2.6.1.1  DRAM DMA Control Register                                  11
  123.     2.6.1.2  DMA Start Address                                          11
  124.     2.6.1.3  DRAM I/O Address                                           12
  125.     2.6.1.4  Timer Control                                              12
  126.     2.6.1.5  Timer 1 and Timer 2 Count                                  12
  127.     2.6.1.6  Sampling Frequency                                         12
  128.     2.6.1.7  Sampling Control Register                                  13
  129.     2.6.1.8  Joystick Trim DAC                                          13
  130.     2.6.1.9  Reset Register                                             14
  131.   2.6.2  Voice-specific Registers                                       14
  132.     2.6.2.1  Voice Control Register                                     15
  133.     2.6.2.2  Frequency Control Register                                 16
  134.     2.6.2.3  Starting location HIGH                                     16
  135.     2.6.2.4  Starting location LOW                                      16
  136.     2.6.2.5  End Address HIGH                                           16
  137.     2.6.2.6  End Address LOW                                            16
  138.     2.6.2.7  Volume Ramp Rate                                           17
  139.     2.6.2.8  Volume Ramp Start                                          17
  140.     2.6.2.9  Volume Ramp End                                            17
  141.     2.6.2.10  Current Volume                                            18
  142.     2.6.2.11  Current Location HIGH                                     18
  143.     2.6.2.12  Current Location LOW                                      18
  144.     2.6.2.13  Pan Position                                              18
  145.     2.6.2.14  Volume Ramp Control Register                              19
  146.     2.6.2.15  Active Voices                                             19
  147.     2.6.2.16  IRQ Source Register                                       20
  148. 2.7  Global Data Low                                                    20
  149. 2.8  Global Data High                                                   20
  150. 2.9  IRQ Status                                                         21
  151. 2.10  Timer Control Register                                            21
  152. 2.11  Timer Data Register                                               21
  153. 2.12  DRAM I/O                                                          21
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160. Section                                                               Page
  161.  
  162. 2.13  Mix Control Register                                              22
  163. 2.14  IRQ Control Register                                              22
  164. 2.15 Register Control                                                   24
  165. 2.16 Volume ramping description                                         24
  166.  
  167.  
  168. Chapter 3 - Programming the UltraSound                                  26
  169. 3.0  Introduction                                                       26
  170. 3.1  Sound                                                              26
  171. 3.2  The Basics of the UltraSound                                       27
  172. 3.3  Using GUS Memory                                                   27
  173. 3.4  What are Samples?                                                  28
  174. 3.5  Using Voices                                                       29
  175. 3.6  Volumes                                                            30
  176. 3.7  Using Looping                                                      30
  177. 3.8  Clicks and click removal                                           31
  178. 3.9  Interrupt Handling Functions                                       32
  179. 3.10 Rollover feature                                                   32
  180. 3.11 Stereo playback                                                    33
  181. 3.12 C-specific information                                             35
  182. 3.13 PASCAL-specific information                                        36
  183.   3.13.1 Available constants and variables                              37
  184.   3.13.2 Examples                                                       39
  185.   3.13.3 Management of GUS RAM                                          40
  186. 3.14 Coming Attractions                                                 41
  187. 3.15 Technical Support                                                  42
  188.  
  189. Chapter 4 - Reference Guide                                             43
  190.   UltraAllocVoice                                                       81
  191.   UltraAuxHandler                                                       54
  192.   UltraCalcRate                                                         43
  193.   UltraClearVoices                                                      81
  194.   UltraClose                                                            43
  195.   UltraDisableLineIn                                                    46
  196.   UltraDisableMicIn                                                     46
  197.   UltraDisableMIDIXmit                                                  58
  198.   UltraDisableOutput                                                    47
  199.   UltraDownload                                                         44
  200.   UltraDRAMDMABusy                                                      45
  201.   UltraDRAMTcHandler                                                    50
  202.   UltraEnableLineIn                                                     47
  203.   UltraEnableMicIn                                                      47
  204.   UltraEnableMIDIXmit                                                   59
  205.   UltraEnableOutput                                                     48
  206.   UltraFreeVoice                                                        82
  207.   UltraGetLineIn                                                        48
  208.   UltraGetMicIn                                                         49
  209.   UltraGetOutput                                                        48
  210.   UltraGoRecord                                                         45
  211.   UltraGoVoice                                                          46
  212.   UltraMaxAlloc                                                         55
  213.   UltraMaxAvail                                                         55
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220. Section                                                               Page
  221.  
  222.   UltraMemAlloc                                                         56
  223.   UltraMemAvail                                                         56
  224.   UltraMemFree                                                          57
  225.   UltraMemInit                                                          57
  226.   UltraMIDIDisableRecv                                                  58
  227.   UltraMIDIEnableRecv                                                   58
  228.   UltraMIDIRecv                                                         59
  229.   UltraMIDIRecvHandler                                                  51
  230.   UltraMIDIReset                                                        60
  231.   UltraMIDIStatus                                                       60
  232.   UltraMIDIXmit                                                         60
  233.   UltraMIDIXmitHandler                                                  51
  234.   UltraOpen                                                             61
  235.   UltraPeekData                                                         62
  236.   UltraPing                                                             62
  237.   UltraPokeData                                                         63
  238.   UltraPrimeRecord                                                      64
  239.   UltraPrimeVoice                                                       65
  240.   UltraProbe                                                            66
  241.   UltraRampLinearVolume                                                 84
  242.   UltraRampVolume                                                       67
  243.   UltraReadLinearVolume                                                 84
  244.   UltraReadRecordPosition                                               67
  245.   UltraReadVoice                                                        68
  246.   UltraReadVolume                                                       68
  247.   UltraRecordData                                                       69
  248.   UltraRecordDMABusy                                                    70
  249.   UltraRecordHandler                                                    54
  250.   UltraReset                                                            70
  251.   UltraSetBalance                                                       71
  252.   UltraSetFrequency                                                     71
  253.   UltraSetLinearVolume                                                  83
  254.   UltraSetLoopMode                                                      71
  255.   UltraSetRecordFrequency                                               72
  256.   UltraSetVoice                                                         72
  257.   UltraSetVoiceEnd                                                      72
  258.   UltraSetVolume                                                        73
  259.   UltraSizeDRAM                                                         73
  260.   UltraStartTimer                                                       74
  261.   UltraStartVoice                                                       75
  262.   UltraStopTimer                                                        75
  263.   UltraStopVoice                                                        76
  264.   UltraStopVolume                                                       76
  265.   UltraTimer1Handler                                                    52
  266.   UltraTimer2Handler                                                    52
  267.   UltraTimerStopped                                                     76
  268.   UltraTrimJoystick                                                     77
  269.   UltraUpload                                                           77
  270.   UltraVectorLinearVolume                                               85
  271.   UltraVectorVolume                                                     78
  272.   UltraVersion                                                          78
  273.   UltraVersionStr                                                       79
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280. Section                                                               Page
  281.  
  282.   UltraVoiceOff                                                         82
  283.   UltraVoiceOn                                                          83
  284.   UltraVoiceStopped                                                     79
  285.   UltraVolumeHandler                                                    53
  286.   UltraVolumeStopped                                                    79
  287.   UltraWaitDRAMDMA                                                      80
  288.   UltraWaitRecordDMA                                                    80
  289.   UltraWaveHandler                                                      53
  290.  
  291.  
  292. Chapter 5 - Focal Point 3D Sound                                        86
  293. 5.0  Introduction                                                       86
  294. 5.1  Creating 3D file                                                   87
  295. 5.2  3D Sound Routines                                                  87
  296.     UltraAbsPosition                                                    87
  297.     UltraAngPosition3D                                                  88
  298.     UltraAngFltPosition3D                                               89
  299.     UltraCloseDup3D                                                     89
  300.     UltrDup3D                                                           90
  301.     UltraLoad3DEffect                                                   91
  302.     UltraSetFreq3D                                                      92
  303.     UltraRelease3DInterleave                                            92
  304.     UltraSetup3DInterleave                                              93
  305.     UltraStart3D                                                        93
  306.     UltraStop3D                                                         94
  307.     UltraUnLoad3DEffect                                                 94
  308.  
  309.  
  310. Appendix A - Error Codes                                                95
  311.  
  312. Appendix B - Volume Control                                             96
  313.  
  314. Appendix C - Voice Control                                              97
  315.  
  316. Appendix D - DMA Control                                                98
  317.  
  318. Appendix E - Recording Control                                          99
  319.  
  320. Appendix F - Patch Files                                               100
  321.   Field descriptions                                                   104
  322.  
  323. Appendix G - 3D File Header                                            109
  324.  
  325.  
  326.  
  327. Ultrasound Software Development Kit (SDK)                      Version 2.10
  328. ___________________________________________________________________________
  329.  
  330.                       Chapter 1 - General Information
  331.  
  332. 1.0 Introduction
  333.  
  334. This is version 2.10 of the Software Development Kit (SDK) for the Advanced
  335. Gravis UltraSound card, and is the combined work of Advanced Gravis,  FORTE
  336. Technologies, and Ingenuity  Software.   This kit  is intended  for use  by
  337. programmers of  IBM-compatible  PCs.   After  becoming familiar  with  this
  338. material, you should be able to use  C or Pascal to program the  UltraSound
  339. under MS-DOS.
  340.  
  341. This is the first version which includes a full Borland Pascal (version  7)
  342. and Turbo-Pascal (versions 6  and 7) interface.   This was written by  Kurt
  343. Kennett of  Ingenuity  Software for  Advanced  Gravis, and  is  the  direct
  344. translation of the routines in the  C interface.  For specific  information
  345. about the Pascal interface, see section 3.13.
  346.  
  347. For specific  information  about  the  revised  and  updated  C  interface,
  348. including compilers and memory models supported, see section 3.12.
  349.  
  350. Some of the discussions of the  hardware interface to the card (Chapter  2)
  351. are quite technical, and  go beyond the  level of technical  sophistication
  352. needed to write software.   Therefore, a seperate  section (Chapter 3)  has
  353. been included which is a general overview of how to write software for  the
  354. card.   What  follows in  this  chapter is  a  general description  of  the
  355. UltraSound card  and its  features, the  MIDI functionality,  the  Joystick
  356. interface, and  the  GF1  32-voice  Sound  Synthesizer.    Throughout  this
  357. documentation,  the  words  'lowlevel  toolkit',  'lowlevel  routines'  and
  358. 'lowlevel code' are  used.   This refers  to any  and all  of the  routines
  359. described and included in the C and/or Pascal interfaces.
  360.  
  361.  
  362.  
  363. 1.1 Features of the UltraSound
  364.  
  365. - Jumper selectable base port address.
  366. - Software selectable IRQ vectors and DMA channels.
  367. - XT and AT compatibility.
  368. - 8 or 16 bit playback: Stereo and Monophonic.
  369. - 8 bit recording:  Stereo or Monophonic.
  370. - Playback and recording rates up to 44.1 kHz.
  371. - 32 voice wavetable synthesis: all voices mixed on board.
  372. - Simultaneous playback and recording is possible.
  373. - Each voice has its own volume settings, volume enveloping, playback  rate
  374.   and balance.
  375. - Both line level and amplified outputs.
  376. - 6850 compatible MIDI UART on-board.
  377. - Gravis Eliminator joystick interface with jumper enable/disable.
  378. - 256Kb DRAM on board for waveforms.  Expandable to 1Mb.
  379. - Stereo microphone input with automatic level control.
  380. - Line level input.
  381. - CD ROM Drive audio input.
  382. - Stereo mini-jacks for line & amplified outputs and Mic and Line inputs.
  383.  
  384.  
  385. ___________________________________________________________________________
  386.                                                                           3
  387.  
  388.  
  389.  
  390. Ultrasound Software Development Kit (SDK)                      Version 2.10
  391. ___________________________________________________________________________
  392.  
  393. 1.2 Benefits of supporting the UltraSound
  394.  
  395. The UltraSound has 32 separate  voices, each of which  can be used to  play
  396. back any 8- or 16-bit digital data that is loaded into its DRAM.  This data
  397. can consist  of individual  sound effects,  a whole  sound track,  or  even
  398. single musical  notes  of  a  digitized  instrument.    The  UltraSound  is
  399. completely controlled  by  the  PC,  thus  giving  maximum  flexibility  to
  400. applications which use it.  The main chip which runs the card (the GF1)  is
  401. directly addressable from the PC's CPU via basic I/O instructions.
  402.  
  403. Here are some of the features that the UltraSound offers:
  404.  
  405. 1) Wavetable synthesis has a much higher sound quality that FM-based cards
  406.    can ever achieve.   This method of audio  synthesis is the same  method
  407.    used in expensive professional keyboards.
  408. 2) 32 digital voices can be  independently controlled. This allows  you to
  409.    have up to 32 sound effects or instruments going at once.
  410. 3) The card is RAM-based.  Since  the instrument patches are kept  on disk
  411.    and only loaded when they are  needed, they can be changed  or improved
  412.    at will.
  413. 4) Focal Point 3D  sound generation.  You can  position your  applications
  414.    sounds anywhere in 3D space around the listener.
  415. 5) All mixing is  done on  the card.   There is  no burden  on the CPU  to
  416.    playback multiple channels.
  417. 6) Multiple cards can be  installed in the same  PC. With some  relatively
  418.    minor adjustments to the SDK software, multiple cards can be controlled
  419.    in the same PC.
  420. 7) Hardware-assisted voice enveloping. A multi-point attack-decay-sustain-
  421.    release  envelope  can  be  implemented  that  uses  virtually  no  CPU
  422.    overhead. Tremelo can also be done in hardware.
  423. 8) Sound effects can be pre-loaded into DRAM, using little or no PC memory
  424.    to keep track of them.  This leaves more space for your application and
  425.    it's data.  It also allows you to start or stop any  sound whenever you
  426.    wish.
  427.  
  428.  
  429.  
  430. 1.3 The GF1 - 32 Voice Sound Synthesizer
  431.  
  432. The UltraSound uses  Wave-Table Synthesis to  produce sound  output.   This
  433. means that either sampled data from actual instruments or other synthesized
  434. digital audio is  stored in DRAM  on the UltraSound  Board.   The GF1  chip
  435. which controls the board  is set up to  play back relatively short  digital
  436. audio samples and produce continuous sound closely reproducing the original
  437. instrument.   The  32  voices  are  independently  controlled  and  can  be
  438. producing different sounds concurently.   Output from  all voices is  mixed
  439. into the left or right channels.  Circuitry in the GF1 can be programmed to
  440. perform the  following audio  processing functions  independently for  each
  441. voice:
  442.  
  443. - Frequency Shifting to produce different notes of the same instrument.
  444.  
  445.  
  446.  
  447.  
  448. ___________________________________________________________________________
  449.                                                                           4
  450.  
  451.  
  452.  
  453. Ultrasound Software Development Kit (SDK)                      Version 2.10
  454. ___________________________________________________________________________
  455.  
  456. - Amplitude Modulation to produce note enveloping (attack, decay,  sustain,
  457.   release), overall  volume control  or special  effects such  as LFO  (low
  458.   frequency amplitude modulation).
  459.  
  460. - Panning the voice from left to right channel outputs.
  461.  
  462. Multi-track digital audio recordings can be played through the GF1 by using
  463. one voice per digital audio track.  The GF1 is compatible with 8 and 16 bit
  464. data, stereo  or  mono, signed  or  unsigned data,  and  8 or  16  bit  DMA
  465. channels.
  466.  
  467. The GF1 is basically a pipeline processor.  It constantly loops from  voice
  468. #0 to the  end of the  active voices (how  to define the  number of  active
  469. voices is shown later). Every 1.6  microseconds, the GF1 performs a  series
  470. of operations on a particular voice.  The more active voices there are, the
  471. longer it takes  between each time  a particular voice  is serviced.   This
  472. puts a limit on  the rate at which  playback can occur.   14 active  voices
  473. will allow a maximum of 44.1  kHz playback.  28  voices will allow 22  kHz.
  474. Faster rates can be achieved by making the frequency constant greater  than
  475. 1.  This will cause the GF1 to skip some  data bytes to play a sample  back
  476. at the requested  frequency.  This  is not generally  a problem, but  could
  477. cause some distortion or aliasing.
  478.  
  479. The formula for calculating the playback rate is:
  480.  
  481.                            Frequency   Active Voices
  482.                              44100          14
  483.                              41160          15
  484.                              38587          16
  485.                              36317          17
  486.                              34300          18
  487.                              32494          19
  488.                              30870          20
  489.                              29400          21
  490.                              28063          22
  491.                              26843          23
  492.                              25725          24
  493.                              24696          25
  494.                              23746          26
  495.                              22866          27
  496.                              22050          28
  497.                              21289          29
  498.                              20580          30
  499.                              19916          31
  500.                              19293          32
  501.  
  502. This table is calculated by knowing that 14 active voices will give exactly
  503. 44.1 kHz  playback.    Therefore,  the voice  servicing  rate  'X'  can  be
  504. calculated from:
  505.  
  506.                       1,000,000 / (X * 14) = 44100 Hz
  507.                        X = 1.619695497 microseconds
  508.  
  509.  
  510.  
  511. ___________________________________________________________________________
  512.                                                                           5
  513.  
  514.  
  515.  
  516. Ultrasound Software Development Kit (SDK)                      Version 2.10
  517. ___________________________________________________________________________
  518.  
  519. Once X is known, the frequency 'divisor' is calculated by:
  520.  
  521.           divisor = 1,000,000 / (1.619695497 * # of active voices)
  522.  
  523. The  lowlevel  code  pre-calculates  this  table  so  that  floating  point
  524. arithmetic doesn't  need to  be done.   A  frequency 'counter'  is used  to
  525. calculate how often  a voice is  updated by the  GF1.  To  calculate an  FC
  526. (frequency counter) for any given frequency  with a particular # of  active
  527. voices, run it through this formula:
  528.  
  529. C:
  530.    fc = (unsigned int)(((speed_khz<<9L)+(divisor>>1L)) / divisor);
  531.    fc = fc << 1;
  532.  
  533. PASCAL:
  534.    fc := Word(((Speed_Khz SHL 9)+(Divisor SHR 1)) DIV Divisor);
  535.    fc := fc SHL 1;
  536.  
  537. The left  shift  is  needed since  the  FC  is in  bits  15-1.    For  more
  538. information about  the  frequency  counter, see  chapter  2,  the  hardware
  539. section.
  540.  
  541. This value  is  then  put  in  the  frequency  control  register  for  that
  542. particular voice.  If the mantissa portion of  the FC is 1, then each  time
  543. around the loop,  the GF1 uses  each data  point to play.   If  there is  a
  544. fractional portion, the GF1 interpolates the  actual data to play from  the
  545. two data points that it is between.  This makes the sound much  'smoother',
  546. since the GF1 will create  points in between the  actual data points.   For
  547. example, assume an 8 bit recording  at 22 kHz and 14  active voices .   The
  548. frequency control register is set up to  1/2 (exponent = 256).  This  means
  549. that every time  around the loop,  that particular  voice's accumulator  is
  550. adjusted by 1/2.  So the first time the  accumulator is 0 and data point  0
  551. is used.  The second time around the  loop, the accumulator is 0.5.   Since
  552. there obviously is no DRAM location 0.5, the GF1 interpolates what the data
  553. would be by looking at location 0 and location 1 and taking the appropriate
  554. ratio from each.  In this case, it picks a point half-way between the  two.
  555. If the recording rate were 11kHz, it would take 25% from location 0 and 75%
  556. from location 1 the first time  through the loop.   The next time it  would
  557. take 50% from each.  The  next time it would take  25% from location 0  and
  558. 75% from location 1.  The fourth time through it uses 100% of location 1.
  559.  
  560. The interpolation  is done  to a  resolution of  16 bits,  even for  8  bit
  561. playback.  This has the  effect of making an  8 bit recording sound  better
  562. when played back on the GF1 than on a standard 8 bit card.
  563.  
  564. Remember that the GF1 works on a voice every 1.6 microseconds.  This  means
  565. that the fewer voices, the faster  each voice gets updated.  The  frequency
  566. control register setting for the voice MUST take this into account.  The FC
  567. must get smaller if the  number of active voices  gets smaller.  This  will
  568. increase the number of points created between the actual data points so the
  569. perceived playback speed remains the same.
  570.  
  571.  
  572.  
  573.  
  574. ___________________________________________________________________________
  575.                                                                           6
  576.  
  577.  
  578.  
  579. Ultrasound Software Development Kit (SDK)                      Version 2.10
  580. ___________________________________________________________________________
  581.  
  582. 1.4 MIDI Interface
  583.  
  584. The MIDI 101 interface consists of  standard UART functionality -  Motorola
  585. MC68C50.  An interrupt  to the PC can  be generated for  each byte of  MIDI
  586. data received or transmitted.  This  hardware is independent of any of  the
  587. other hardware.  The main MIDI circuitry is included in the GF1  processor,
  588. but external to the chip is an optical isolator that is used on the  serial
  589. input data and an open collector driver that is used for the serial output.
  590. In addition, external logic is included on board to loop back transmit data
  591. to the receive  data under software  control.  The  serial interface has  a
  592. fixed configuration  with no  programmable options,  as  in the  MC6850.  A
  593. control register is  used to enable  and disable  the interrupt  generation
  594. logic.  A status register is used  to determine if the transmit or  receive
  595. register is interrupting.  A read or write to the data register clears  the
  596. interrupt status.
  597.  
  598. The specifications for the interface are:
  599.  
  600.                               31.25 kHz +- 1%
  601.                                asynchronous
  602.                                 1 start bit
  603.                                 8 data bits
  604.                                 1 stop bit
  605.  
  606. The MIDI signals  are available  on the  15 pin  D connector  used for  the
  607. joystick.  An external cable assembly  containing the optical isolator  and
  608. driver is required to use the MIDI interface.
  609.  
  610.  
  611.  
  612. 1.5 Joystick Interface
  613.  
  614. The joystick  interface is  an Eliminator  Joystick interface  designed  by
  615. Advanced Gravis.   It basically consists  of a single  eight bit  register.
  616. When written to, four  flip-flops are reset  and comparator inputs  (LM339)
  617. begin to charge up based on the  position of the joystick.  The  comparator
  618. threshold is setup in the GF1.   Crossing the threshold of the  comparators
  619. cause the  flip-flops to  be preset  and the  capacitor to  be  discharged.
  620. Reads of the register return the  state of four digital inputs  (internally
  621. pulled up) and the state of the flip-flops.   The rate of discharge of  the
  622. capacitors has a minimum time constant of 1 microsecond.
  623.  
  624. UltraSound boards with a revision version (printed on the card) of 3.3  and
  625. lower have  a jumper  which is  used  to enable  or disable  the  joystick.
  626. Boards  with  a  revision  version  of  3.4  and  above  have  a   software
  627. enable/disable for the joystick instead of  a jumper.  There is a  joystick
  628. SDK available sperately from Gravis.
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637. ___________________________________________________________________________
  638.                                                                           7
  639.  
  640.  
  641.  
  642. Ultrasound Software Development Kit (SDK)                      Version 2.10
  643. ___________________________________________________________________________
  644.  
  645.                      Chapter 2 - Hardware Information
  646.  
  647. 2.1  I/O Port Map
  648.  
  649. The following  describes I/O  address map  used on  the board.  The 'X'  is
  650. defined by the  jumper settings  on the  UltraSound and  should match  that
  651. specified in the ULTRASND environment variable.
  652.  
  653.      INTERFACE                         I/O,MEM,  R,W       ADDRESS
  654.                                        INT,DMA             HEX
  655.      ------------------------------------------------------------
  656.      UltraSound Base Port:              ---       --        2X0
  657.  
  658.      MIDI Interface:
  659.           Control                       I/O       W         3X0
  660.           Status                        I/O       R         3X0
  661.           Transmit Data                 I/O       W         3X1
  662.           Receive Data                  I/O       R         3X1
  663.           Joystick Interface:
  664.             Trigger Timer               I/O       W         201
  665.             Read Data                   I/O       R         201
  666.  
  667.      GF1 Synthesizer:
  668.           GF1 Page Register             I/O       R/W       3X2
  669.           GF1/Global Register Select    I/O       R/W       3X3
  670.           GF1/Global Data Low Byte      I/O       R,W       3X4
  671.           GF1/Global Data High Byte     I/O       R/W       3X5
  672.           IRQ Status Register 1=ACTIVE  I/O       R         2X6
  673.           Timer Control Reg             I/O       R/W       2X8
  674.           Timer Data                    I/O       W         2X9
  675.           DRAM                          I/O       R,W       3X7
  676.           DRAM                          DMA       R,W       1,3,5,6,7
  677.           Record Digital Audio          DMA       R         1,3,5,6,7
  678.           BOARD ONLY
  679.             Mix Control register        I/O       W         2X0
  680.             IRQ  control register       I/O       W         2XB
  681.             (2X0- bit 6 = 1)
  682.             DMA control register        I/O       W         2XB
  683.             (2X0- bit 6 = 0)
  684.             Register Controls           I/O       R/W       2XF (Rev 3.4+)
  685.             Mixer Control               I/O       W         3X6 (Rev 3.7+)
  686.  
  687. At power-up the board  has operational Joystick  and MIDI interfaces.  This
  688. allows their direct use with existing software. The GF1 ASIC powers up with
  689. all voices disabled,  not requiring a  software initialization. This  helps
  690. eliminate noise at powerup and allows  the Joystick and MIDI interfaces  to
  691. be used by existing applications. The  IRQ control register MUST be set  up
  692. before  the  MIDI  interface  can  generate  an  IRQ.    This  is  done  in
  693. ULTRINIT.EXE and when an  application sets up the  latches to the  ULTRASND
  694. parameters.
  695.  
  696.  
  697.  
  698.  
  699.  
  700. ___________________________________________________________________________
  701.                                                                           8
  702.  
  703.  
  704.  
  705. Ultrasound Software Development Kit (SDK)                      Version 2.10
  706. ___________________________________________________________________________
  707.  
  708. 2.2  MIDI Control Port - 3X0
  709.  
  710. Here are the bit definitions  for the MIDI control  byte. It is located  at
  711. address 3X0 hex and is write only.
  712.  
  713.      =================================
  714.      | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  715.      =================================
  716.        |   |   |   |   |   |   |   |
  717.        |   |   |   |   |   |   |   +---- 1 \ Master reset (when set)
  718.        |   |   |   |   |   |   +-------- 1 /
  719.        |   |   |   |   |   +------------ Reserved
  720.        |   |   |   |   +---------------- Reserved
  721.        |   |   |   +-------------------- Reserved
  722.        |   |   +------------------------ 1 \ xmit IRQ enabled
  723.        |   +---------------------------- 0 /
  724.        +-------------------------------- 1 = Receive IRQ enabled
  725.  
  726. Bit 0 & 1 will cause  a master reset when toggled  high and then low.  They
  727. must be  left low  when using  port. This  will normally  cause a  transmit
  728. buffer empty IRQ.
  729.  
  730.  
  731.  
  732. 2.3  MIDI Status Port - 3X0
  733.  
  734. Here are the bit definitions for  the MIDI status byte.   It is located  at
  735. address 3X0 hex and is read-only.
  736.  
  737.      =================================
  738.      | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  739.      =================================
  740.        |   |   |   |   |   |   |   |
  741.        |   |   |   |   |   |   |   +---- Receive reg. full
  742.        |   |   |   |   |   |   +-------- Transmit reg. empty
  743.        |   |   |   |   |   +------------ Reserved
  744.        |   |   |   |   +---------------- Reserved
  745.        |   |   |   +-------------------- Framing Error
  746.        |   |   +------------------------ Overrun error
  747.        |   +---------------------------- Reserved
  748.        +-------------------------------- Interrupt pending
  749.  
  750. The MIDI control interface behaves identically to a 6850 UART.
  751.  
  752.  
  753.  
  754. 2.4  MIDI Data Port - 3X1
  755.  
  756. The transmit and receive registers are at 3X1 hex and are 8 bits wide.
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763. ___________________________________________________________________________
  764.                                                                           9
  765.  
  766.  
  767.  
  768. Ultrasound Software Development Kit (SDK)                      Version 2.10
  769. ___________________________________________________________________________
  770.  
  771. 2.5  Page Register - 3X2
  772.  
  773. This could also be called the voice select register. This register is  used
  774. to specify which voice's registers you  want to read/write. This value  can
  775. range from 0 to  the number of active  voices specified (13-31). Once  this
  776. has been specified, you may select the specific register within that voice.
  777. Be careful that  IRQs are  off during  the time  that the  page and  select
  778. registers are  being  modified.  This  will  prevent  the  foreground  from
  779. selecting a voice and having the background change it in the background.
  780.  
  781.  
  782.  
  783. 2.6  Select Register - 3X3
  784. 2.6.1  Global Registers
  785.  
  786. These are the global registers. They are not voice-specific.
  787.  
  788.                Address     Mode    Width   Description
  789.  
  790.                  41        R/W       8     DRAM DMA Control
  791.                  42        W        16     DMA Start Address
  792.                  43        W        16     DRAM I/O Address (LOW)
  793.                  44        W         8     DRAM I/O Address (HIGH)
  794.                  45        R/W       8     Timer Control
  795.                  46        W         8     Timer 1 Count
  796.                  47        W         8     Timer 2 Count
  797.                  48        W         8     Sampling Frequency
  798.                  49        R/W       8     Sampling Control
  799.                  4B        W         8     Joystick trim DAC
  800.                  4C        R/W       8     RESET
  801.  
  802.  
  803.  
  804.  
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826. ___________________________________________________________________________
  827.                                                                          10
  828.  
  829.  
  830.  
  831. Ultrasound Software Development Kit (SDK)                      Version 2.10
  832. ___________________________________________________________________________
  833.  
  834. 2.6.1.1  DRAM DMA Control Register - (41)
  835.  
  836.      =================================
  837.      | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  838.      =================================
  839.        |   |   |   |   |   |   |   |
  840.        |   |   |   |   |   |   |   +---- Enable DMA (1=go)
  841.        |   |   |   |   |   |   +-------- DMA direction (1=read)
  842.        |   |   |   |   |   +------------ DMA channel width
  843.        |   |   |   |   +---------------- \
  844.        |   |   |   +-------------------- / DMA Rate divider
  845.        |   |   +------------------------ DMA IRQ Enable
  846.        |   +---------------------------- (R) DMA IRQ Pending
  847.        |                                 (W) DATA SIZE (0=8bit,1=16bit)
  848.        +-------------------------------- Invert MSB (write only)
  849.  
  850. Bit 0 -  Enable the  DMA  channel. The  GF1  will begin  sending  DMA  ACK
  851.          protocol. If PC  DMA controller  is programmed,  data will  begin
  852.          being transferred.  If not,  data  will move  as  soon as  it  is
  853.          programmed.
  854. Bit 1 -  DMA  transfer  direction.  Read  is   taking  data  OUT  of   the
  855.          UltraSound, Write sends data to it.
  856. Bit 2 -  0 = if DMA channel is an 8 bit channel (0-3).
  857.          1 = If it is a 16 bit channel (4-7)
  858.            Note: This is INDEPENDENT of the data size.
  859. Bit 3,4 -DMA Rate divisor. The Maximum rate is approx 650 khz.
  860.            00 = divide by 1
  861.            01 = divide by 2
  862.            10 = divide by 3
  863.            11 = divide by 4
  864. Bit 5 -  DMA terminal count interrupt enable
  865. Bit 6 -  Read  - DMA terminal count IRQ pending
  866.          Write - Data size 0 = 8 Bit data
  867.                            1 = 16 bit data
  868.              Note: Data size is independent of channel size
  869. Bit 7 -  1 = Invert High bit to flip data to twos complement form.
  870.              Note: This flips bit 7 for 8 bit data and bit 15 for
  871.                    16 bit data.
  872.  
  873.  
  874.  
  875. 2.6.1.2  DMA Start Address - (42)
  876.  
  877. Bits 15-0 are Address lines 19-4.
  878.  
  879. This register defines where the DMA will  transfer data to or from.   Since
  880. only the upper 16 address bits are used and the lower 4 bits are set to  0,
  881. a DMA transfer MUST begin on an 16 byte  boundary for an 8 bit DMA  channel
  882. (0-3). If a 16 bit DMA channel is being used, the transfer MUST being on  a
  883. 32 byte boundary. An  additional address translation is  necessary if a  16
  884. bit DMA  channel  is used.  For  simple example  code  on how  to  do  this
  885. translation, see the C function convert_to_16().
  886.  
  887.  
  888.  
  889. ___________________________________________________________________________
  890.                                                                          11
  891.  
  892.  
  893.  
  894. Ultrasound Software Development Kit (SDK)                      Version 2.10
  895. ___________________________________________________________________________
  896.  
  897. 2.6.1.3  DRAM I/O Address (43,44)
  898.  
  899. These 2 registers allow you to specify an address to peek and poke directly
  900. into UltraSound DRAM. Register 43 is  the lower 16 address lines.  Register
  901. 44 is the upper 4 address lines. (bits 0-3). Read or write to register  3X7
  902. to get at the address location.
  903.  
  904.  
  905.  
  906. 2.6.1.4  Timer Control - (45)
  907.  
  908.           =================================
  909.           | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  910.           =================================
  911.             |   |   |   |   |   |   |   |
  912.             |   |   |   |   |   |   |   +---- Reserved (Set to 0)
  913.             |   |   |   |   |   |   +-------- Reserved (Set to 0)
  914.             |   |   |   |   |   +------------ Enable Timer 1 IRQ
  915.             |   |   |   |   +---------------- Enable Timer 2 IRQ
  916.             |   |   |   +-------------------- Reserved (Set to 0)
  917.             |   |   +------------------------ Reserved (Set to 0)
  918.             |   +---------------------------- Reserved (Set to 0)
  919.             +-------------------------------- Reserved (Set to 0)
  920.  
  921.  
  922.  
  923. 2.6.1.5  Timer 1 and Timer 2 Count - (46,47)
  924.  
  925. These counts are loaded by the application  and then they will count up  to
  926. $FF and generate  and IRQ.  Timer 1 has  a granularity  of 80  microseconds
  927. (0.00008 sec) and Timer  2 has a granularity  of 320 microseconds  (0.00032
  928. sec).
  929.  
  930.  
  931.  
  932. 2.6.1.6  Sampling Frequency - (48)
  933.  
  934. The formula for calculating this value is:
  935.      rate = 9878400/(16*(FREQ+2))
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952. ___________________________________________________________________________
  953.                                                                          12
  954.  
  955.  
  956.  
  957. Ultrasound Software Development Kit (SDK)                      Version 2.10
  958. ___________________________________________________________________________
  959.  
  960. 2.6.1.7  Sampling Control Register - (49)
  961.  
  962.           =================================
  963.           | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  964.           =================================
  965.             |   |   |   |   |   |   |   |
  966.             |   |   |   |   |   |   |   +---- Start sampling
  967.             |   |   |   |   |   |   +-------- Mode (0=mono, 1=stereo)
  968.             |   |   |   |   |   +------------ DMA width (0=8bit,1=16bit)
  969.             |   |   |   |   +---------------- Reserved (Set to 0)
  970.             |   |   |   +-------------------- Reserved (Set to 0)
  971.             |   |   +------------------------ DMA IRQ enable
  972.             |   +---------------------------- (Read) DMA IRQ pending
  973.             +-------------------------------- Invert MSB
  974.  
  975. Bit 0 -If PC DMA controller is programmed, it will begin sampling as  soon
  976.        as this is enabled.
  977. Bit 1 -0 = mono
  978.        1 = stereo
  979.        In stereo mode, the order of the  data bytes is left is first,  and
  980.        right is second. If a 16 bit data  channel is used, the left is  in
  981.        the lower byte.
  982. Bit 2 -DMA Channel width (0 = 8 bit, 1 = 16 bit)
  983. Bit 5 -Enable DMA terminal count IRQ
  984. Bit 6 -DMA terminal count IRQ pending
  985. Bit 7 -Flip bit 7 to get non-twos compliment data
  986.  
  987.  
  988.  
  989. 2.6.1.8  Joystick Trim DAC - (4B)
  990.  
  991. This register is initialized to 4.3 volts (value = 29). It only needs to be
  992. modified to  account  for faster/slower  machines.  A utility  is  provided
  993. (ULTRAJOY.EXE) that  sets this  up.   There should  be no  reason for  your
  994. application to modify this register.
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015. ___________________________________________________________________________
  1016.                                                                          13
  1017.  
  1018.  
  1019.  
  1020. Ultrasound Software Development Kit (SDK)                      Version 2.10
  1021. ___________________________________________________________________________
  1022.  
  1023. 2.6.1.9  Reset Register - (4C)
  1024.  
  1025.      =================================
  1026.      | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  1027.      =================================
  1028.        |   |   |   |   |   |   |   |
  1029.        |   |   |   |   |   |   |   +---- Master Reset
  1030.        |   |   |   |   |   |   +-------- DAC Enable
  1031.        |   |   |   |   |   +------------ GF1 Master IRQ Enable
  1032.        |   |   |   |   +---------------- Reserved (Set to 0)
  1033.        |   |   |   +-------------------- Reserved (Set to 0)
  1034.        |   |   +------------------------ Reserved (Set to 0)
  1035.        |   +---------------------------- Reserved (Set to 0)
  1036.        +-------------------------------- Reserved (Set to 0)
  1037.  
  1038. Bit 0 -GF1 Master Reset. 0 = reset,  1 = run. As long as  this is a 0,  it
  1039.        will be held in a reset state.
  1040. Bit 1 -Enable DAC output. DAC's will not run unless this bit is set.
  1041. Bit 2 -Master IRQ enable.  This bit MUST  be set  to get ANY  of the  GF1-
  1042.        generated IRQs (wavetable, volume, etc).
  1043.  
  1044. This register will normally contain the value $07 while your application is
  1045. running.
  1046.  
  1047.  
  1048.  
  1049. 2.6.2  Voice-specific Registers
  1050.  
  1051. The following are the voice-specific registers. Each voice has its own bank
  1052. of read and write  registers that alter its  behavior. The write  registers
  1053. range from 0 to F and the corresponding read registers range from 80 to 8F.
  1054. To convert from the write to the read, just add 80 hex.
  1055.  
  1056.           Write    Read     Width   Description
  1057.             0       80        8     Voice Control
  1058.             1       81       16     Frequency Control
  1059.             2       82       16     Starting Address (HIGH)
  1060.             3       83       16     Starting Address (LOW)
  1061.             4       84       16     End Address (HIGH)
  1062.             5       85       16     End Address (LOW)
  1063.             6       86        8     Volume Ramp Rate
  1064.             7       87        8     Volume Ramp Start
  1065.             8       88        8     Volume Ramp End
  1066.             9       89       16     Current Volume
  1067.             A       8A       16     Current Address (HIGH)
  1068.             B       8B       16     Current Address (LOW)
  1069.             C       8C        8     Pan Position
  1070.             D       8D        8     Volume Control
  1071.             E       8E        8     Active Voices (Voice independent)
  1072.             -       8F        8     IRQ Status (Voice independent)
  1073.  
  1074. There are several 'self-modifying' bits  defined for these registers.  This
  1075. means that the GF1 may change them at anytime  on its own. Due to the  fact
  1076. that the software must accommodate this phenomena, it is possible that  the
  1077.  
  1078. ___________________________________________________________________________
  1079.                                                                          14
  1080.  
  1081.  
  1082.  
  1083. Ultrasound Software Development Kit (SDK)                      Version 2.10
  1084. ___________________________________________________________________________
  1085.  
  1086. GF1 may change something immediately  after your application has  set/reset
  1087. one of  the bits.  This is  due to  the GF1's  pipeline processor  type  of
  1088. architecture: it does  a read-modify-write cycle,  and if your  application
  1089. modifies one of these bits AFTER it has done the read portion and BEFORE it
  1090. does the write portion, it's possible for the chip to perform  incorrectly.
  1091. To overcome this, you need to do a  double write (with a delay in  between)
  1092. when those particular  bits are  involved. This delay  must be  at least  3
  1093. times the length of time necessary  to process a voice. (3*1.6  microsecs).
  1094. In the lowlevel code,  this is done with  a function called GF1_Delay.  The
  1095. self-modifying bits are  designated with an  (*) after  the particular  bit
  1096. definition.
  1097.  
  1098. Changing the start and  end points of  a voice while  its playing can  have
  1099. some strange side  effects. For example,  if you change  end poistion to  a
  1100. lower location than it is currently playing, you will get and IRQ (if  they
  1101. are enabled). Also, since the high  and low bytes are set individually  and
  1102. asynchronously to when the GF1 is working on a voice, it is possible to get
  1103. an unexpected IRQ if the current  position and the new end position cross.
  1104.  
  1105.  
  1106.  
  1107. 2.6.2.1  Voice Control Register - (0,80)
  1108.  
  1109.      =================================
  1110.      | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  1111.      =================================
  1112.        |   |   |   |   |   |   |   |
  1113.        |   |   |   |   |   |   |   +---- Voice Stopped
  1114.        |   |   |   |   |   |   +-------- Stop Voice
  1115.        |   |   |   |   |   +------------ 16 bit data
  1116.        |   |   |   |   +---------------- Loop enable
  1117.        |   |   |   +-------------------- Bi-directional loop enable
  1118.        |   |   +------------------------ Wave table IRQ
  1119.        |   +---------------------------- Direction of movement
  1120.        +-------------------------------- IRQ pending
  1121.  
  1122. * Bit 0- 1 = Voice is  stopped. This gets set  by hitting the end  address
  1123.          (not looping) or by setting bit 1 in this reg.
  1124.   Bit 1- 1 = Stop Voice. Manually force voice to stop.
  1125.   Bit 2- 1 = 16 bit wave data, 0 = 8 bit data
  1126.   Bit 3- 1 = Loop to begin address when it hits the end address.
  1127.   Bit 4- 1 = Bi-directional looping enabled
  1128.   Bit 5- 1 = Enable wavetable IRQ. Generate an IRQ when the voice hits the
  1129.          end address. Will generate IRQ even if looping is enabled.
  1130. * Bit 6- 1 = Decreasing addresses, 0 =  increasing addresses. It is  self-
  1131.          modifying because it might shift directions  when it hits one  of
  1132.          the loop boundaries and looping is enabled.
  1133. * Bit 7- 1 = Wavetable IRQ  pending. If IRQ's are  enabled and looping  is
  1134.          NOT enabled, an IRQ will be constantly generated until  the voice
  1135.          is stopped. This means  that you may  get more than  1 IRQ if  it
  1136.          isn't handled properly.
  1137.  
  1138.  
  1139.  
  1140.  
  1141. ___________________________________________________________________________
  1142.                                                                          15
  1143.  
  1144.  
  1145.  
  1146. Ultrasound Software Development Kit (SDK)                      Version 2.10
  1147. ___________________________________________________________________________
  1148.  
  1149. 2.6.2.2  Frequency Control Register - (1,81)
  1150.  
  1151.      Bits 15-10 - Integer Portion
  1152.      Bits 9-1   - Fractional Portion
  1153.      Bit 0      - Not used.
  1154.  
  1155. This register  determines the  amount added  to  (or subtracted  from)  the
  1156. current position of the voice to determine where the next position will be.
  1157. This is how the interpolated data points are determined. If the FC register
  1158. is less than 0, the GF1 will interpolate the data point in between the  two
  1159. actual data points. Note that the FC can be greater than 1. This allows for
  1160. skipping over data bytes.  The actual frequency that  it will play back  is
  1161. directly related to the number of active voice specified (register 8E).
  1162.  
  1163.  
  1164.  
  1165. 2.6.2.3  Starting location HIGH - (2,82)
  1166.  
  1167. Bits 12-0  are the HIGH 13 bits of the address of the starting location of
  1168.            the waveform (Addr lines 19-7).
  1169. Bits 15-13 are not used.
  1170.  
  1171.  
  1172.  
  1173. 2.6.2.4  Starting location LOW - (3,83)
  1174.  
  1175. Bits 15-9  are the low 7 bits of  the address of the starting location  of
  1176.            the waveform. (Addr lines 6-0).
  1177. Bits 8-5   are the fractional part of the starting address.
  1178. Bits 4-0   are not used.
  1179.  
  1180.  
  1181.  
  1182. 2.6.2.5  End Address HIGH - (4,84)
  1183.  
  1184. Bits 12-0  are the high 13 bits of  the address of the ending location  of
  1185.            the waveform. (Addr lines 19-7)
  1186. Bits 15-13 are not used.
  1187.  
  1188.  
  1189.  
  1190. 2.6.2.6  End Address LOW - (5,85)
  1191.  
  1192. Bits 15-9  are the low 7 bits of the address of the ending location of the
  1193.            waveform. (Addr lines 6-0).
  1194. Bits 8-5   are the fractional part of the ending address.
  1195. Bits 4-0   are not used.
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204. ___________________________________________________________________________
  1205.                                                                          16
  1206.  
  1207.  
  1208.  
  1209. Ultrasound Software Development Kit (SDK)                      Version 2.10
  1210. ___________________________________________________________________________
  1211.  
  1212. 2.6.2.7  Volume Ramp Rate - (6,86)
  1213.  
  1214. Bits 5-0   is the amount added to (or subtracted from) the  current volume
  1215.            to get the next volume. The  range is from 1 to 63.  The larger
  1216.            the number, the greater the volume step.
  1217. Bits 7-6   defines the rate at which the increment is applied.
  1218.  
  1219. Please see section 2.16 for more information on hardware volume ramping.
  1220.  
  1221.  
  1222.  
  1223. 2.6.2.8  Volume Ramp Start - (7,87)
  1224.  
  1225. Bits 7-4   Exponent
  1226. Bits 3-0   Mantissa
  1227.  
  1228. This register specifies  the starting position  of a volume  ramp. See  the
  1229. special section on volume  ramping for a more  complete explanation of  how
  1230. this register works.
  1231.  
  1232. Please see section 2.16 for more information on hardware volume ramping.
  1233.  
  1234.  
  1235.  
  1236. 2.6.2.9  Volume Ramp End - (8,88)
  1237.  
  1238. Bits 7-4   Exponent
  1239. Bits 3-0   Mantissa
  1240.  
  1241. This register specifies  the ending  position of a  volume ramp.   See  the
  1242. special section on volume  ramping for a more  complete explanation of  how
  1243. this register works.
  1244.  
  1245. Note:   The starting volume must always be less than the ending volume. If
  1246.         you want the volume  to ramp down, turn  on the decreasing  volume
  1247.         bit in the Volume Control Register.
  1248.  
  1249. Please see section 2.16 for more information on hardware volume ramping.
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267. ___________________________________________________________________________
  1268.                                                                          17
  1269.  
  1270.  
  1271.  
  1272. Ultrasound Software Development Kit (SDK)                      Version 2.10
  1273. ___________________________________________________________________________
  1274.  
  1275. 2.6.2.10  Current Volume - (9,89)
  1276.  
  1277. * Bits 15-12   Exponent
  1278. * Bits 11-4    Mantissa
  1279.   Bits 3-0     Reserved (Set to 0)
  1280.  
  1281. Note:   This register has 4 extra bits of precision that is  necessary for
  1282.         finer granularity of volume  placement.  The  extra bits are  used
  1283.         during a volume ramp.
  1284.  
  1285. Note:   This is a self-modifying value. The GF1 will update  this register
  1286.         as it ramps.
  1287.  
  1288. Note:   You should always  set this  register equal  to the  value of  the
  1289.         beginning of the volume ramp (start OR end).
  1290.  
  1291. Please see section 2.16 for more information on hardware volume ramping.
  1292.  
  1293.  
  1294.  
  1295. 2.6.2.11  Current Location HIGH - (A,8A)
  1296.  
  1297. Bits 15-13 Reserved (Set to 0)
  1298. Bits 12-0  High 13 bits of address (address lines 19-7)
  1299.  
  1300.  
  1301.  
  1302. 2.6.2.12  Current Location LOW - (B,8B)
  1303.  
  1304. Bits 15-9  Low 7 bits of address. (address lines 6-0)
  1305. Bits 8-0   9 bit fractional position.
  1306.  
  1307.  
  1308.  
  1309. 2.6.2.13  Pan Position - (C,8C)
  1310.  
  1311. Bits 8-4   Reserved (Set to 0)
  1312. Bits 3-0   Pan position. (0=full left, 15=full right)
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.  
  1328.  
  1329.  
  1330. ___________________________________________________________________________
  1331.                                                                          18
  1332.  
  1333.  
  1334.  
  1335. Ultrasound Software Development Kit (SDK)                      Version 2.10
  1336. ___________________________________________________________________________
  1337.  
  1338. 2.6.2.14  Volume Ramp Control Register - (D,8D)
  1339.  
  1340.      =================================
  1341.      | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  1342.      =================================
  1343.        |   |   |   |   |   |   |   |
  1344.        |   |   |   |   |   |   |   +---- Ramp Stopped
  1345.        |   |   |   |   |   |   +-------- Stop Ramp
  1346.        |   |   |   |   |   +------------ Rollover condition
  1347.        |   |   |   |   +---------------- Loop Enable
  1348.        |   |   |   +-------------------- Bi-directional loop enable
  1349.        |   |   +------------------------ Volume ramp IRQ enable
  1350.        |   +---------------------------- Direction
  1351.        +-------------------------------- IRQ pending
  1352.  
  1353. * Bit 0- Show the ramp has stopped
  1354.   Bit 1- Manually stop the ramp.
  1355.   Bit 2- Roll over condition. This bit pertains more towards  the location
  1356.          of the voice rather than its  volume. Its purpose is to  generate
  1357.          an IRQ and NOT stop  (or loop). It will  generate an IRQ and  the
  1358.          voice's address  will continue  to move  thru  DRAM in  the  same
  1359.          direction. This can  be a  very powerful feature.  It allows  the
  1360.          application to get  an interrupt without  having the sound  stop.
  1361.          This can be easily used to implement a ping-pong buffer algorithm
  1362.          so an application can keep feeding  it data and there will be  no
  1363.          pops. Even if looping is enabled, it will not loop.
  1364.   Bit 3- Enable looping. Loop from end to start (or start to end).
  1365.   Bit 4- Enable bi-directional looping.  When it  hits end  (or start)  it
  1366.          will change directions and proceed toward the other limit.
  1367.   Bit 5- Enable getting an IRQ when ramp hits end.
  1368. * Bit 6- Ramp direction. 0=increasing, 1=decreasing.
  1369. * Bit 7- (READ) Volume ramp IRQ pending.
  1370.  
  1371. Please see section 2.16 for more information on hardware volume ramping.
  1372.  
  1373.  
  1374.  
  1375. 2.6.2.15  Active Voices - (E,8E)
  1376.  
  1377. Bits 7-6   Must be set to a 1
  1378. Bits 5-0   # of voices to enable - 1.
  1379.  
  1380. The range is from 14 - 32. Any value less than 14 will be forced to 14.
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393. ___________________________________________________________________________
  1394.                                                                          19
  1395.  
  1396.  
  1397.  
  1398. Ultrasound Software Development Kit (SDK)                      Version 2.10
  1399. ___________________________________________________________________________
  1400.  
  1401. 2.6.2.16  IRQ Source Register - (F,8F)
  1402.  
  1403.      =================================
  1404.      | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  1405.      =================================
  1406.        |   |   |   |   |   |   |   |
  1407.        |   |   |   |   |   |   |   +----\
  1408.        |   |   |   |   |   |   +-------- \
  1409.        |   |   |   |   |   +------------  - Interrupting voice #
  1410.        |   |   |   |   +---------------- /
  1411.        |   |   |   +--------------------/
  1412.        |   |   +------------------------ 1
  1413.        |   +---------------------------- Volume Ramp IRQ pending
  1414.        +-------------------------------- WaveTable IRQ pending
  1415.  
  1416. Bit 4-1-Voice # (0-31) of interrupting voice
  1417. Bit 5-  ALWAYS a 1
  1418. Bit 6-  0 = Volume Ramp IRQ occurred
  1419. Bit 7-  0 = Wavetable IRQ occurred
  1420.  
  1421. Note:   This is  a global  read only  register. There  is only  1 for  ALL
  1422.         voices. You MUST service any indicated IRQ's since a read  of this
  1423.         port will clear the associated IRQ bits in the  particular voice's
  1424.         control and/or volume control registers.
  1425.  
  1426. Note:   It is possible that multiple  voices could interrupt at  virtually
  1427.         the same time.  In this  case, this  register will  behave like  a
  1428.         fifo. When in your IRQ handler, keep reading (and  servicing) this
  1429.         register until you do a read with  both IRQ bits set to a  1. This
  1430.         means there are no voice IRQs left to deal with.
  1431.  
  1432. Note:   Since it is possible  to get ANOTHER IRQ  from the same voice  for
  1433.         the SAME  reason, you  must ignore  any subsequent  IRQ from  that
  1434.         voice while in the IRQ handler. For example, when a voice hits its
  1435.         end position and  generates an  IRQ back to  your application,  it
  1436.         will continue to generate IRQ's until either the voice is stopped,
  1437.         the IRQ enable is turned off, or the end location is moved.
  1438.  
  1439.  
  1440.  
  1441. 2.7  Global Data Low - 3X4
  1442.  
  1443. This register can be used to do either a 16 bit transfer for one of the  16
  1444. bit wide  GF1 registers  (Start addr  high etc)  when using  a 16  bit  I/O
  1445. instruction or the low part of a 16 bit  wide register when using an 8  bit
  1446. I/O instruction.
  1447.  
  1448.  
  1449.  
  1450. 2.8  Global Data High - 3X5
  1451.  
  1452. This register is used to do either an 8 bit  transfer for one of the GF1  8
  1453. bit registers or to do the high part of a 16 bit wide register.
  1454.  
  1455.  
  1456. ___________________________________________________________________________
  1457.                                                                          20
  1458.  
  1459.  
  1460.  
  1461. Ultrasound Software Development Kit (SDK)                      Version 2.10
  1462. ___________________________________________________________________________
  1463.  
  1464. 2.9  IRQ Status - 2X6
  1465.  
  1466. CAUTION: Note that this is at 2X6 *** NOT 3X6 ***.
  1467.  
  1468.      =================================
  1469.      | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  1470.      =================================
  1471.        |   |   |   |   |   |   |   |
  1472.        |   |   |   |   |   |   |   +---- MIDI Transmit IRQ
  1473.        |   |   |   |   |   |   +-------- MIDI Receive IRQ
  1474.        |   |   |   |   |   +------------ Timer 1 IRQ
  1475.        |   |   |   |   +---------------- Timer 2 IRQ
  1476.        |   |   |   +-------------------- Reserved (Set to 0)
  1477.        |   |   +------------------------ WaveTable IRQ (any voice)
  1478.        |   +---------------------------- Volume Ramp IRQ (any voice)
  1479.        +-------------------------------- DMA TC IRQ (DRAM or Sample)
  1480.  
  1481.  
  1482.  
  1483. 2.10  Timer Control Register - 2X8
  1484.  
  1485. This register  maps to  the  same location  as  the ADLIB  board's  control
  1486. register. Writing a 4 here selects  the timer stuff. Bit  6 will be set  if
  1487. timer #1 has expired. Bit 5 will be set it timer #2 has expired.
  1488.  
  1489.  
  1490.  
  1491. 2.11  Timer Data Register - 2X9
  1492.  
  1493.      =================================
  1494.      | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  1495.      =================================
  1496.        |   |   |   |   |   |   |   |
  1497.        |   |   |   |   |   |   |   +---- Timer 1 Start
  1498.        |   |   |   |   |   |   +-------- Timer 2 Start
  1499.        |   |   |   |   |   +------------ Reserved (Set to 0)
  1500.        |   |   |   |   +---------------- Reserved (Set to 0)
  1501.        |   |   |   +-------------------- Reserved (Set to 0)
  1502.        |   |   +------------------------ Mask Timer 2
  1503.        |   +---------------------------- Mask Timer 1
  1504.        +-------------------------------- Reset Timer IRQ
  1505.  
  1506.      Bit 0 - Start up timer #1
  1507.      Bit 1 - Start up timer #2
  1508.      Bit 5 - Mask off timer 2
  1509.      Bit 6 - Mask off timer 1
  1510.      Bit 7 - Clear Timer IRQ
  1511.  
  1512.  
  1513. 2.12  DRAM I/O - 3X7
  1514.  
  1515. This register is used to read or write  data at the location pointed at  by
  1516. registers 43 and 44. This is used to peek and poke directly to DRAM.
  1517.  
  1518.  
  1519. ___________________________________________________________________________
  1520.                                                                          21
  1521.  
  1522.  
  1523.  
  1524. Ultrasound Software Development Kit (SDK)                      Version 2.10
  1525. ___________________________________________________________________________
  1526.  
  1527. 2.13  Mix Control Register - 2X0
  1528.  
  1529.      =================================
  1530.      | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  1531.      =================================
  1532.        |   |   |   |   |   |   |   |
  1533.        |   |   |   |   |   |   |   +---- 0=Enable Line IN
  1534.        |   |   |   |   |   |   +-------- 0=Enable Line OUT
  1535.        |   |   |   |   |   +------------ 1=Enable MIC IN
  1536.        |   |   |   |   +---------------- Enable latches
  1537.        |   |   |   +-------------------- Combine chan1 IRQ with Chan2
  1538.        |   |   +------------------------ Enable MIDI loopback TxD to RxD
  1539.        |   +---------------------------- Control Reg Select
  1540.        +-------------------------------- Reserved (Set to 0)
  1541.  
  1542. Bit 0 -Enable UltraSound line Input
  1543. Bit 1 -Enable UltraSound Line output
  1544. Bit 2 -Enable Stereo Mic Input
  1545. Bit 3 -Enable latches.This  provides power  to the  DMA/IRQ latches.  Once
  1546.        these are enabled, NEVER disable them.   Disabling them will  cause
  1547.        random IRQ's in the PC  since the DMA and  IRQ lines are not  being
  1548.        driven any more.
  1549. Bit 4 -Combine Channel 1 (GF1) IRQ's with Channel 2 (MIDI)
  1550. Bit 5 -Enable MIDI  loopback. Any  data sent  out  Transmit port  will  be
  1551.        looped back into the input port.
  1552. Bit 6 -Control Register Select. When this is set to a 1, the next IO write
  1553.        to 2XB will be to the IRQ control latches. When this is set to a 0,
  1554.        the next IO write to  2XB will be to  the DMA channel latches.  The
  1555.        write to 2XB for either of these MUST occur as the NEXT IOW or else
  1556.        the write to  2XB will  be locked  out and  not occur.  This is  to
  1557.        prevent an application  that is  probing for  cards to  accidentaly
  1558.        corrupt the latches.
  1559.  
  1560.  
  1561.  
  1562. 2.14  IRQ Control Register - 2XB
  1563.  
  1564.      IRQ  control register         I/O       W         2XB
  1565.      (2X0- bit 6 = 1)
  1566.  
  1567.      Bits 2-0 Channel 1 (GF1) IRQ Selector
  1568.          0=No Interrupt
  1569.          1=IRQ2
  1570.          2=IRQ5
  1571.          3=IRQ3
  1572.          4=IRQ7
  1573.          5=IRQ11
  1574.          6=IRQ12
  1575.          7=IRQ15
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582. ___________________________________________________________________________
  1583.                                                                          22
  1584.  
  1585.  
  1586.  
  1587. Ultrasound Software Development Kit (SDK)                      Version 2.10
  1588. ___________________________________________________________________________
  1589.  
  1590.      Bits 5-3 Channel 2 (MIDI) IRQ selector
  1591.          0=No Interrupt
  1592.          1=IRQ2
  1593.          2=IRQ5
  1594.          3=IRQ3
  1595.          4=IRQ7
  1596.          5=IRQ11
  1597.          6=IRQ12
  1598.          7=IRQ15
  1599.  
  1600.     Bit 6 1 = Combine Both IRQS using Channel 1's IRQ
  1601.     Bit 7 Reserved (Set to 0)
  1602.  
  1603. Note:   If the channels are sharing an IRQ, channel 2's IRQ must be set to
  1604.         0 and turn on bit 6. A bus conflict will occur if both latches are
  1605.         programmed with the same IRQ #.
  1606.  
  1607.  
  1608.      DMA control register          I/O       W         2XB
  1609.      (2X0- bit 6 = 0)
  1610.  
  1611.      Bits 2-0 DMA Select Register 1
  1612.         0=NO DMA
  1613.         1=DMA1
  1614.         2=DMA3
  1615.         3=DMA5
  1616.         4=DMA6
  1617.         5=DMA7
  1618.  
  1619.      Bits 5-3 DMA Select Register 2
  1620.         0=NO DMA
  1621.         1=DMA1
  1622.         2=DMA3
  1623.         3=DMA5
  1624.         4=DMA6
  1625.         5=DMA7
  1626.  
  1627.     Bit 6 - Combine Both on the same DMA channel.
  1628.     Bit 7 - Reserved (Set to 0).
  1629.  
  1630. Note:   If the channels are sharing an DMA, channel 2's DMA must be set to
  1631.         0 and turn on bit 6. A bus conflict will occur if both latches are
  1632.         programmed with the same DMA #.
  1633.  
  1634. C programmers can refer to the  UltraSetInterface routine in INIT.C of  the
  1635. lowlevel source code for the proper sequence for programming these latches.
  1636. If the order is not right, unpredictable things may happen.
  1637.  
  1638. Changing the IRQ settings will usually cause an IRQ on the OLD IRQ  because
  1639. it is no longer being driven low by the  latches and it will tend to  float
  1640. up. That low to high transition causes an IRQ on the PC. Normally, this  is
  1641. not a problem, but it is something to be aware of.
  1642.  
  1643.  
  1644.  
  1645. ___________________________________________________________________________
  1646.                                                                          23
  1647.  
  1648.  
  1649.  
  1650. Ultrasound Software Development Kit (SDK)                      Version 2.10
  1651. ___________________________________________________________________________
  1652.  
  1653. 2.15 Register Control - 2XF
  1654.  
  1655. This register is  only valid  for UltraSound boards  that are  at or  above
  1656. revision 3.4.  It is  not valid  for  boards which  have a  prior  revision
  1657. number.
  1658.  
  1659. On 3.4 and  above boards,  there is a  bank of  6 registers  that exist  at
  1660. location 2XB. Register 2XF is used to select which one is being talked to.
  1661.  
  1662. Register #     Use
  1663.  
  1664.      0         Same as pre-3.4 boards
  1665.      1-4       Unused - Reserved
  1666.      5         Write a 0 to clear IRQs on power-up
  1667.      6         'Jumper register'
  1668.  
  1669.  
  1670.    Jumper register definition:
  1671.  
  1672.      =================================
  1673.      | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  1674.      =================================
  1675.        |   |   |   |   |   |   |   |
  1676.        |   |   |   |   |   |   |   +---- Reserved (Set to 0)
  1677.        |   |   |   |   |   |   +-------- 1=Enable MIDI port addr decode
  1678.        |   |   |   |   |   +------------ 1=Enable joystick port decode
  1679.        |   |   |   |   +---------------- Reserved (Set to 0)
  1680.        |   |   |   +-------------------- Reserved (Set to 0)
  1681.        |   |   +------------------------ Reserved (Set to 0)
  1682.        |   +---------------------------- Reserved (Set to 0)
  1683.        +-------------------------------- Reserved (Set to 0)
  1684.  
  1685.  
  1686.  
  1687. 2.16 Volume ramping description
  1688.  
  1689. The UltraSound has built-in volume ramping to facilitate the implementation
  1690. of the attack decay sustain release envelopes.  This ramping uses the  same
  1691. principle as the voices for updating the  volume values.  A section of  the
  1692. envelope can be programmed such  that the PC does  not need to be  burdened
  1693. with the task of changing each volume  at specified intervals.  At the  end
  1694. of that  particular section,  an IRQ  can  be generated  so that  the  next
  1695. section can be programmed in.
  1696.  
  1697. This continues until the entire envelope has been completed.  The start and
  1698. end points as well as the increment rate are fully programmable.
  1699.  
  1700. The hardware volume registers and bit definitions are:
  1701.  
  1702.       Current Volume (9,89)    EEEEMMMMMMMM    (Bits 15-4)
  1703.  
  1704.       Volume Start   (7,87)    EEEEMMMM        (Bits 7-0)
  1705.  
  1706.       Volume End     (8,88)    EEEEMMMM        (Bits 7-0)
  1707.  
  1708. ___________________________________________________________________________
  1709.                                                                          24
  1710.  
  1711.  
  1712.  
  1713. Ultrasound Software Development Kit (SDK)                      Version 2.10
  1714. ___________________________________________________________________________
  1715.  
  1716.  
  1717.       Volume Incr    (6,86)    RRMMMMMM        (Bits 7-0)
  1718.  
  1719. Once the current  volume, start and  end volumes are  programmed, the  only
  1720. thing left  is to  set up  the volume  increment register.   This  register
  1721. determines how fast the  ramp takes place and  with what granularity.   The
  1722. finer the granularity, the smoother (but  slower) the ramp.  The  increment
  1723. register has 2 fields.   The first  is the amount  added to (or  subtracted
  1724. from) the current volume to get to the next one.  These are the low 6  bits
  1725. and can range from 1 to  63.  A 1  is a long, slow  ramp compared to a  63.
  1726. The upper  2 bits  determine how  often  the increment  is applied  to  the
  1727. current volume.  The rate bits are defined as:
  1728.  
  1729.  Rate Bits       Volume Update Rate
  1730.      00                FUR    (FUR = 1/(1.6*#active voices))
  1731.      01                FUR/8
  1732.      10                FUR/64
  1733.      11                FUR/512
  1734.  
  1735. Each rate increment is 8 times longer  than the preceding one.  This  means
  1736. that the value to store for the fastest possible ramp is 1Fh (63), and  the
  1737. value for the slowest  possible ramp is 1Ch  (193).  The approximate  times
  1738. for a full scale volume ramp (0-4095) are:
  1739.  
  1740.                 Rate    Vol Inc    14 Voices     32 Voices
  1741.                 ----    -------    ---------     ---------
  1742.                   0       63         1.4 ms        3.3 ms
  1743.                   0        1        91.7 ms      209.7 ms
  1744.                   1       63        11.5 ms       26.2 ms
  1745.                   1        1       733.8 ms        1.7 sec
  1746.                   2       63        91.8 ms      209.7 ms
  1747.                   3        1         5.9 sec      13.4 sec
  1748.                   3       63       734.0 ms        1.7 sec
  1749.                   3        1        47.0 sec     107.3 sec
  1750.  
  1751. Note that these  times are for  full sweep ramping.   Since  a volume  ramp
  1752. usually goes between points  in between the limits,  the actual ramp  times
  1753. will be much smaller.
  1754.  
  1755. Allowing to let the volume ramps to go  to the extremes can cause a  random
  1756. oscillation of the volume when it reaches the limits.  This is caused by an
  1757. overshoot past  the limit  due to  a large  step size.   The  SDK  routines
  1758. protect against this by limiting how close to the rails you can get.
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771. ___________________________________________________________________________
  1772.                                                                          25
  1773.  
  1774.  
  1775.  
  1776. Ultrasound Software Development Kit (SDK)                      Version 2.10
  1777. ___________________________________________________________________________
  1778.  
  1779.                   Chapter 3 - Programming the UltraSound
  1780.  
  1781. 3.0 Introduction
  1782.  
  1783. The UltraSound is frequently referred to as 'GUS', for Gravis'  UltraSound.
  1784. The card has  a very good  reputation among programmers,  since it is  very
  1785. easy to program using a high level language, and provides incredible sound.
  1786. However, there are some things that you need to be aware of to successfully
  1787. program  the  board.    Users  of  either  language  should  consult  their
  1788. respective example programs  before attempting to  use the card.   Also,  C
  1789. users should  consult  section  3.12, while  Pascal  users  should  consult
  1790. section 3.13.
  1791.  
  1792.  
  1793.  
  1794. 3.1 Sound
  1795.  
  1796. A sound is something that you hear. It is produced by a source and received
  1797. by the ears of the listener.  There are several mediums for the storage  of
  1798. sound, including vinyl, magnetic surfaces, and more recently optical disks.
  1799.  
  1800. When something makes a sound, it creates waves of different air  intensity.
  1801. These waves are registered as 'sound',  and the amplitude and frequency  of
  1802. these waves determine the 'type' of sound.
  1803.  
  1804. Amplitude is determined by the highest  and lowest points of the wave,  and
  1805. is registered by  your ear  as the  volume of  the sound.   Therefore,  the
  1806. loudness of a  sound is  changed by varying  the amplitude  of the  sound's
  1807. wave.  Frequency is determined by the number of pulses (passes of a  single
  1808. wave peak and trough)  which pass a  certain point in  a certain amount  of
  1809. time.  The measure  of sound frequency is  done using the standard  measure
  1810. for frequency - Hertz (Hz).  The higher the frequency, the higher the pitch
  1811. of the sound that is heard.
  1812.  
  1813. Normal sound  like speech  and sound  that comes  from mixes  of  different
  1814. instruments  is  a  very  complex  pattern  of  changes  in  amplitude  and
  1815. frequency.  To record the wave's  pattern, a computer takes a large  number
  1816. of 'samples' of the wave produced by the sound.  Then when it goes  through
  1817. the individual  'samples' at  the  same rate  they  were recorded,  it  can
  1818. reconstruct the original  wave and produce  a sound which  is close to  the
  1819. original sound.  If the  sample rate is not  high enough, the computer  can
  1820. miss changes in the amplitude and frequency, and the sound reproduced  will
  1821. not sound exactly like the original sound.
  1822.  
  1823. The number of  samples taken each  second is referred  to as the  'sampling
  1824. rate', and the number of samples played back each second is referred to  as
  1825. the 'playback rate'.   When a rock  band plays a  song, the combined  sound
  1826. wave produced by the singers and  instruments is produced.  To record  this
  1827. wave at CD-quality on a computer medium  (like memory or a hard disk),  the
  1828. wave is 'sampled' 44100 times each second.  Since the number of samples per
  1829. second is a frequency, this rate is measured again in Hertz.  Therefore, we
  1830. say that the recording frequency is 44.1 kHz.
  1831.  
  1832.  
  1833.  
  1834. ___________________________________________________________________________
  1835.                                                                          26
  1836.  
  1837.  
  1838.  
  1839. Ultrasound Software Development Kit (SDK)                      Version 2.10
  1840. ___________________________________________________________________________
  1841.  
  1842. If I  record a  sound  at 44.1  kHz  for two  seconds,  I will  have  88200
  1843. individual 'samples'.  The data that comprises these 'samples' is typically
  1844. referred to as a 'sample' itself.
  1845.  
  1846. When a recording made at 44.1 kHz is played back at 44.1 kHz, the  original
  1847. sound is reproduced almost exactly.   Note that the recording and  playback
  1848. frequency are different from the frequency of the sound itself.
  1849.  
  1850. Most other sound cards do not have any  RAM on them, and therefore have  to
  1851. use the PC's RAM to store the sounds  they produce.  This leaves less  room
  1852. for application programs,  and is just  another thing that  the CPU has  to
  1853. track and process - slowing down the machine.
  1854.  
  1855. On the UltraSound,  samples are  stored on  the card  in it's  DRAM.   This
  1856. leaves more  space in  PC RAM  for programs.   Also,  the GF1  chip in  the
  1857. UltraSound can play  32 independent sounds  at once without  using any  CPU
  1858. time - so the machine doesn't slow down at all!
  1859.  
  1860.  
  1861.  
  1862. 3.2 The Basics of the UltraSound
  1863.  
  1864. The only things  you need  to know to  set up  the card  when your  program
  1865. starts is the maximum  # of voices you  are going to  need and the  maximum
  1866. playback frequency you're going to need for any sample.
  1867.  
  1868. Consult the  frequency table  in section  1.3 to  see how  many voices  you
  1869. should initialize the  card with.   If  you don't  need a  large number  of
  1870. voices,  initializing  the  card  to  use  fewer  voices  means  that  some
  1871. 'oversampling' will occur, making the sound better in quality.  You  cannot
  1872. initialize for fewer than 14 voices or larger than 32.
  1873.  
  1874. To open the card, you call  the UltraOpen function.   This will set up  the
  1875. interrupt vectors and control procedures for  the card, and then reset  the
  1876. card to use the number of voices you  specify.  When you are finished  with
  1877. the card, you need  to close it so  that the interrupt procedures,  voices,
  1878. and volumes  get stopped  and reset  to 'normal'.   To  do this,  call  the
  1879. UltraClose function.  Please see chapter  4, the reference guide, for  more
  1880. information on the syntax and usage of these routines.
  1881.  
  1882.  
  1883. 3.3 Using GUS Memory
  1884.  
  1885. The UltraSound has a default amount of 256K of memory on the card that  can
  1886. be upgraded in 256K increments up to 1 MB.   If you are developing for  the
  1887. card, you may  want to upgrade  to a full  megabyte.  Also,  you should  be
  1888. aware that many users of the  card do NOT have 1  MB of RAM installed,  and
  1889. that if you are going to load samples  into the card's memory, you need  to
  1890. check to  make sure  you  have enough  room.   The  function  UltraMaxAlloc
  1891. (additionally  for   Pascal   users   the   functions   UltraMemAvail   and
  1892. UltraMaxAvail) will  tell  you  how much  RAM  you  still  have  available.
  1893. Because of the  way the  GUS memory  is structured  physically, you  cannot
  1894. allocate chunks larger than 256k at one time.
  1895.  
  1896.  
  1897. ___________________________________________________________________________
  1898.                                                                          27
  1899.  
  1900.  
  1901.  
  1902. Ultrasound Software Development Kit (SDK)                      Version 2.10
  1903. ___________________________________________________________________________
  1904.  
  1905. The C and  Pascal versions  of the SDK  use different  methods for  keeping
  1906. track of blocks of memory that  have been allocated and blocks that  remain
  1907. free.  The C version uses a small portion of  GUS RAM to keep track of  the
  1908. blocks, whereas  the Pascal  version uses  a small  amount of  normal  heap
  1909. space.  In any event, you do not have to worry about the internal operation
  1910. of these routines.  To see  how the Pascal version  uses a small amount  of
  1911. heap space to manage GUS memory, see section 3.13.3.
  1912.  
  1913. The memory allocation routines will ONLY return 32 byte aligned  addresses,
  1914. so if your application uses them, this will not be a problem. If you  chose
  1915. not to  use the  allocation routines  provided, be  sure and  follow  these
  1916. rules.  To obtain a legal block of UltraSound RAM that is guaranteed to  be
  1917. aligned on a 32-byte boundary, use the UltraMemAlloc function.  To free  up
  1918. the memory after  you have used  it, use the  UltraMemFree function.   Once
  1919. again, see chapter  4, the  reference guide,  for more  information on  the
  1920. syntax and usage of these routines.
  1921.  
  1922. You DO NOT necessarily need to  use the memory allocation and  deallocation
  1923. routines to program the card.  You DO have  to be careful if you choose  to
  1924. do without them.  The DMA can only begin on a 16 or 32 byte boundary. An  8
  1925. bit DMA channel (0-3) must start on a 16  byte boundary while a 16 bit  DMA
  1926. channel (4-7) must start on a 32  byte boundary. If an improper address  is
  1927. supplied, the address will be truncated down when the DMA occurs.  A DMA to
  1928. or from the card cannot cross a 256K boundary.
  1929.  
  1930. To send data from  PC memory to the  card, use the UltraDownload  function.
  1931. To read data from  the card into PC  memory, use the UltraUpload  function.
  1932. If you download data to the card, ensure that  if the data is not in  two's
  1933. compliment form you convert it to two's compliment on the download.  To  do
  1934. this, use the DMA control bits (see Appendix D).  Any data you Upload  from
  1935. the card that is playable will be in two's compliment format.
  1936.  
  1937.  
  1938.  
  1939. 3.4 What are Samples?
  1940.  
  1941. As mentioned above, a 'sample' is raw data that has been recorded using the
  1942. GUS or another digital  sound recording device.   Most of these files  will
  1943. have extensions of .SND or .WAV.  There are other extensions available, but
  1944. these are the most common.
  1945.  
  1946. A technique  known as  'frequency shifting'  is sometimes  used to  produce
  1947. alternate 'notes' of a specified instrument.  Amiga '.MOD' file players use
  1948. this technique to  make a single  instrument sample  sound differently  for
  1949. each note played over 3 octaves.   Essentially, the technique utilizes  the
  1950. 12-note scale with  the principle  that each half-step  is 1/12  root of  2
  1951. times the  value of  its predecessor  in frequency  (working from  left  to
  1952. right).  For  instance,  if  we  take  C  as  (1*frequency),  C#  would  be
  1953. (1.05946*frequency).  Since there are 12 notes in an octave, when you reach
  1954. B (the end of the octave), the next note is (2*frequency) - so doubling the
  1955. original frequency means you raise the note one octave.
  1956.  
  1957.  
  1958.  
  1959.  
  1960. ___________________________________________________________________________
  1961.                                                                          28
  1962.  
  1963.  
  1964.  
  1965. Ultrasound Software Development Kit (SDK)                      Version 2.10
  1966. ___________________________________________________________________________
  1967.  
  1968. There is a  drawback to the  technique mentioned above.   If  a sample  was
  1969. recorded at 11kHz for two seconds, and  then played back at 22kHz to  raise
  1970. the note one  octave, it would  only play for  one second  instead of  two.
  1971. This is because you have (11025 * 2 seconds) = 22050 bytes of data.  If you
  1972. play this at  22050 Hz,  or 22050 bytes  per second,  you will  have one  1
  1973. second of sound.  Thus, if you raise or lower the frequency in this manner,
  1974. the sound will  respectively take  a shorter or  longer amount  of time  to
  1975. play.
  1976.  
  1977. A common problem with samples is that the start and/or end of them is at  a
  1978. reasonably high amplitude.  When the sample starts and/or stops, the values
  1979. flowing through the DACs on the card change suddenly.  This usually results
  1980. in an audible 'click' or 'pop' through the speakers.  Section 3.8 looks  at
  1981. the removal of this and other types of clicks and pops than can occur.
  1982.  
  1983.  
  1984.  
  1985. 3.5 Using Voices
  1986.  
  1987. Depending on the number you choose when opening (or initializing) the card,
  1988. you can use anywhere  from 14 to 32  voices at once.   You can look at  the
  1989. voices as those of the people in a choir.  You can tell the voices to start
  1990. or stop  singing (UltraStartVoice,  UltraStopVoice),  sing at  a  specified
  1991. pitch or frequency (UltraSetFrequency),  loudly or softly  (UltraSetVolume,
  1992. UltraSetLinearVolume), and at a specified balance (UltraSetBalance).
  1993.  
  1994. The exciting thing  about the  voices is  that any  number of  them can  be
  1995. played at once, and there is no extra drain on the CPU if you are playing a
  1996. larger number of voices as  opposed to a smaller  one.  Also, these  voices
  1997. can play any type of sampled sound, 8- or 16-bit, at frequencies up to 44.1
  1998. kHz.  Any number of voices can even play the same sample at the same time.
  1999.  
  2000. To start  up  a voice,  you  use the  UltraStartVoice  or  UltraPrimeVoice/
  2001. UltraGoVoice combination.  Either one of these two routines will ask for  a
  2002. voice number, as  well as a  begin, start, and  end location.   The  reason
  2003. begin and start locations are both asked for is in case you wish to play  a
  2004. sample backwards or  loop at a  specific position which  is not the  start.
  2005. The following diagram may make this clearer:
  2006.  
  2007.                              Forward playing:
  2008.                              ================
  2009.                      -------->------->-------->------|
  2010.                                   ^---------<------<-|
  2011.                  Begin ...... Start Loop......... End Loop
  2012.                  location ... location  ......... location
  2013.  
  2014.                              Backward playing:
  2015.                              =================
  2016.                   |------<-----<------<------<----------
  2017.                               |--------->----->---->---^
  2018.                End Loop.... Start Loop............... Begin
  2019.                location .... location ................location
  2020.  
  2021.  
  2022.  
  2023. ___________________________________________________________________________
  2024.                                                                          29
  2025.  
  2026.  
  2027.  
  2028. Ultrasound Software Development Kit (SDK)                      Version 2.10
  2029. ___________________________________________________________________________
  2030.  
  2031. A voice starts at the 'begin' location, and continues playing until it hits
  2032. the 'end' location.  If the 'begin'  is a greater location than the  'end',
  2033. the sample will be played backwards.  The 'start' location is the start  of
  2034. the loop if looping is  enabled for the voice  begin played.  Depending  on
  2035. whether and how you wish  to loop the voice,  you can make various  effects
  2036. occur.  Looping of the voices is discussed in the next section.
  2037.  
  2038. When you have finished with a  voice, You should stop it  (UltraStopVoice),
  2039. and deallocate  it  (UltraFreeVoice).   Please  see section  3.8  on  click
  2040. removal for information on problems with stopping a voice abruptly.
  2041.  
  2042.  
  2043. 3.6 Volumes
  2044.  
  2045. A volume is available for each voice.  If the volume for a voice is not set
  2046. to zero, the data at the position of the voice's accumulator will be summed
  2047. into the final  output.  Therefore,  it is important  that if  you are  not
  2048. using a voice you should set it's volume to zero.
  2049.  
  2050. The UltraSound uses logarithmic volumes using  an exponent and a  mantissa.
  2051. For detailed information  about how the  volumes work,  please see  section
  2052. 2.16.  As an alternative to using  the logarithmic units, a table has  been
  2053. provided in the lowlevel  code which gives linear  equivalents of the  full
  2054. volume range.  You can therefore use the logarithmic volume routines or the
  2055. linear volume routines - whichever your application requires.
  2056.  
  2057. Volumes for each voice may be 'ramped'.  This means that you can specify  a
  2058. start and end volume, and the card will smoothly change the volume from the
  2059. beginning level to the end level.  In ramping the volumes, a 'rate' must be
  2060. specified which assigns how fast the volume is changed.  Please see section
  2061. 2.16 for detailed information on how to set up a volume ramp rate.
  2062.  
  2063.  
  2064.  
  2065. 3.7 Using Looping
  2066.  
  2067. You can loop both voices  and volumes on the  UltraSound.  Looping a  voice
  2068. can result in  sustaining a  particular note,  the generation  of a  unique
  2069. sound, or any number  of other 'special effects'.   Looping the volume  can
  2070. result in a tremelo effect at various intervals.
  2071.  
  2072. Looping a sample is a simple task of setting the mode bits when  specifying
  2073. the start of  a voice (through  UltraPrimeVoice, UltraStartVoice), or  when
  2074. using UltraSetLoopMode.  See appendix C  for a definition of which bits  in
  2075. the mode byte control looping.  Also,  Pascal users should be aware of  the
  2076. constants that are available for use instead (see section 3.13).
  2077.  
  2078. Looping the  volume is  essentially as  simple as  looping a  voice.   When
  2079. specifying the  volume  for a  particular  voice (using  UltraSetVolume  or
  2080. UltraSetLinearVolume), you set the  volume mode byte  depending on how  you
  2081. wish to loop the volume.  See appendix B for a definition of which bits  in
  2082. the mode byte control looping.
  2083.  
  2084.  
  2085.  
  2086. ___________________________________________________________________________
  2087.                                                                          30
  2088.  
  2089.  
  2090.  
  2091. Ultrasound Software Development Kit (SDK)                      Version 2.10
  2092. ___________________________________________________________________________
  2093.  
  2094. 3.8 Clicks and click removal
  2095.  
  2096. As was mentioned in  a few of the  preceding sections, 'clicks' and  'pops'
  2097. can occur when the output of  the DAC changes suddenly.   This is the  most
  2098. frequent type of click, since there  may not be a  way to control the  data
  2099. values the voices are trying to play.
  2100.  
  2101. In general, it is necessary to remember that all voices are being summed in
  2102. to the  final output,  even if  they  are not  running.   This  means  that
  2103. whatever data value that  the voice is pointing  at is contributing to  the
  2104. summation.  It is important that a voice be  pointed to a known value at  a
  2105. known location after it is  stopped so that some  control is kept over  it.
  2106. For instance, if a voice  were left at whereever  the end position was  for
  2107. the last time it played, a pop could  occur if new data were either  DMA'ed
  2108. or poked over the  top of it.   For this reason, it  is recommended that  a
  2109. voice be pointed to a location containing a 0 and that its volume be set to
  2110. 0.  At  that point,  the voice  will have  no contribution  to the  output.
  2111. There are some particular cases where clicks most frequently occur:
  2112.  
  2113. During Reset
  2114. - Because of  the way  the card  is  reset, a  pop  can occur  through  the
  2115.   speakers when a reset occurs.  The way  to remove this pop is to  disable
  2116.   the output, reset the card, and then enable the output again.
  2117.  
  2118. During a balance sweep
  2119. - Since there are  only 16 pan  positions and there  is such  a large  jump
  2120.   between individual positions,  a relatively fast  balance sweep from  one
  2121.   side to another may produce  clicks.  You can  get a very smooth  balance
  2122.   sweep using 2 voices and volume  ramping.  Set one  voice up to one  side
  2123.   and one to the other, and ramp one down from volume X to zero at the same
  2124.   rate as you ramp the other from 0 up to volume  X.  The result is a  very
  2125.   smooth balance sweep.
  2126.  
  2127. When starting and stopping a voice
  2128. - By setting up fairly fast rates when  a sample start or ends and  ramping
  2129.   up or down appropriately, any pop created  by a sudden change in the  DAC
  2130.   value will be summed in at such a low volume, it will never be heard.
  2131.  
  2132. End points not set properly
  2133. - Make sure your end points are at the ends  of your samples. It is a  very
  2134.   common mistake  to set  an end  point to  1 sample  beyond the  end.  For
  2135.   example, if a sample is 100 bytes long an starts at location 100, the end
  2136.   point is at position 199,  NOT position 200.   Also, it is possible  that
  2137.   the GF1 will interpolate data at points beyond the end point.  To  ensure
  2138.   that this does not cause  'clicks', use a few  extra bytes after the  end
  2139.   point of the sample to maintain it.
  2140.  
  2141. Loop points not set properly
  2142. - The same problem as  stated above (end points)  is common for loop  start
  2143.   and end points.   Be sure that the  data at the end  of the loop and  the
  2144.   beginning of the  loop are  practically identical,  since if  there is  a
  2145.   large step between them  a click will result  because the DAC value  will
  2146.   change suddenly.
  2147.  
  2148.  
  2149. ___________________________________________________________________________
  2150.                                                                          31
  2151.  
  2152.  
  2153.  
  2154. Ultrasound Software Development Kit (SDK)                      Version 2.10
  2155. ___________________________________________________________________________
  2156.  
  2157. 3.9 Interrupt Handling Functions
  2158.  
  2159. There are 9 functions  (procedures for Pascal users)  which can be used  to
  2160. define a handler for events that happen under interrupt on the  UltraSound.
  2161. These are  NOT interrupt  handlers but  are  callbacks from  the  interrupt
  2162. handler.  This  means that  they should not  be defined  as interrupt  type
  2163. functions but must adhere to the general  rules of interrupt code.  No  DOS
  2164. calls should be made and care must be taken not to cause problems with code
  2165. running in the foreground.
  2166.  
  2167.               UltraDramTcHandler          UltraRecordHandler
  2168.               UltraMIDIXmitHandler        UltraMIDIRecvHandler
  2169.               UltraTimer1Handler          UltraTimer2Handler
  2170.               UltraWaveHandler            UltraVolumeHandler
  2171.                               UltraAuxHandler
  2172.  
  2173. All these routines  return the old  callback address so  chaining could  be
  2174. done if desired.  This not usually necessary.  It is also not necessary  to
  2175. restore the handler  back to  the old  one when  exiting your  application.
  2176. However, the  UltraClose function  MUST be  called  to restore  the  actual
  2177. interrupt handler.
  2178.  
  2179. These will only be CALLED if  the interrupt for the particular function  is
  2180. enabled in the mode parameter (see the Appendices for the bit definitions.)
  2181. It is  also not  necessary to  set up  a callback  since it  has a  default
  2182. associated with it.
  2183.  
  2184. You should be able to make any SDK library calls from within the  interrupt
  2185. handlers.    All  the  library  functions  protect  themselves  from  being
  2186. interrupted while doing critical operations.
  2187.  
  2188.  
  2189.  
  2190. 3.10 Rollover feature
  2191.  
  2192. Each voice  has a  'rollover'  feature that  allows  an application  to  be
  2193. notified when a voice's playback position passes over a particular place in
  2194. DRAM.  This  is very useful  for getting seamless  digital audio  playback.
  2195. Basically, the GF1 will generate an IRQ when a voice's current position  is
  2196. equal to the end position.  However, instead of stopping or looping back to
  2197. the start position, the voice will continue playing in the same  direction.
  2198. This means that there will be no pause (or gap) in the playback.  Note that
  2199. this feature is enabled/disabled thru  the voice's VOLUME control  register
  2200. (since there are no more bits available in the voice control registers).  A
  2201. voice's loop enable  bit takes precedence  over the rollover.   This  means
  2202. that if a  voice's loop enable  is on, it  will loop when  it hits the  end
  2203. position, regardless of the state of the rollover enable.
  2204.  
  2205. A simple example of this technique is:
  2206.  
  2207. 1)   Allocate a chunk of DRAM: 20K, for example.
  2208. 2)   Load the entire 20K with wave data.
  2209. 3)   Start up a voice with looping disabled and rollover enabled.  Set  its
  2210.      end position to the MIDDLE of the buffer.
  2211.  
  2212. ___________________________________________________________________________
  2213.                                                                          32
  2214.  
  2215.  
  2216.  
  2217. Ultrasound Software Development Kit (SDK)                      Version 2.10
  2218. ___________________________________________________________________________
  2219.  
  2220. 4)   When the voice hits  the middle, you  will get an  IRQ, but the  voice
  2221.      will continue to play.
  2222. 5)   At this point, enable looping and disable the rollover.  Also, set the
  2223.      end position to the end of the  buffer. This will make the voice  loop
  2224.      back to the beginning without stopping.
  2225. 6)   Now load the FIRST 10K with more  wave data. This will make sure  that
  2226.      there is correct data to play when the voice loops.
  2227. 7)   When the voice loops, you will get and IRQ.
  2228. 8)   At this  point,  disable looping,  enable  rollover and  set  the  end
  2229.      position back to the middle of the buffer.
  2230. 9)   Now load the SECOND 10K with more wave data. This will make sure  that
  2231.      there is corect data to play when the rollover occurs.
  2232. 10)  Continue in a loop, starting at step #4.
  2233.  
  2234. Note:This algorithm does not take care  of an initial condition where  not
  2235.      enough data  exists to  fill one  complete  buffer. It  also  doesn't
  2236.      address how  to finish  playing the  last incomplete  buffer.   These
  2237.      points are left up to your implementation to resolve.
  2238.  
  2239.  
  2240.  
  2241. 3.11 Stereo playback
  2242.  
  2243. Stereo data is represented in an interleaved format, meaning that the  data
  2244. alternates between a sample for the left channel and a sample for the right
  2245. channel.  It is either the  responsibility of the hardware or the  software
  2246. to ensure that the data gets used properly. Stereo data can be played  back
  2247. two completely different  ways, either under  software control or  hardware
  2248. control:
  2249.  
  2250. Software Control
  2251. ================
  2252.  
  2253. This is  the most  flexible method,  since it  allows for  playback at  any
  2254. frequency.  The basic  algorithm is to de-interleave  the data into a  left
  2255. channel buffer  and a  right channel  buffer,  then send  the data  to  two
  2256. independent voices  on  the card.    Here is  a  brief description  of  the
  2257. algorithm that would be used:
  2258.  
  2259. 1)   Allocate 2 voices. One for left and one for right.
  2260. 2)   Set the left voice pan position all the way left.
  2261. 3)   Set the right voice pan position all the way right.
  2262. 4)   Set both voice volumes to the same value.
  2263. 5)   Allocate 2 chunks of UltraSound DRAM of the same size, say 20K apiece.
  2264. 6)   Read in 40K of stereo data.
  2265. 7)   De-interleave data into 20K of left data and 20K of right data.
  2266. 8)   DMA left buffer into DRAM buffer #1.
  2267. 9)   DMA right buffer into DRAM buffer #2.
  2268. 10)  Prime right voice to loop on all 20K of data forever. No IRQ.
  2269. 11)  Prime left voice  to play 10K  of its data  with the rollover  feature
  2270.      enabled (See discussion on seamless digital playback above).
  2271. 12)  Start both channels  up as close  together as possible  so they  track
  2272.      together. The right  channel will not  be touched, except  to DMA  new
  2273.      data into its buffer.
  2274.  
  2275. ___________________________________________________________________________
  2276.                                                                          33
  2277.  
  2278.  
  2279.  
  2280. Ultrasound Software Development Kit (SDK)                      Version 2.10
  2281. ___________________________________________________________________________
  2282.  
  2283. 13)  At this point the software will loop on the following steps until  the
  2284.      data is exhausted. The rollover will  allow the software to play  half
  2285.      the buffer and  get notified when  it has finished,  but the  playback
  2286.      will continue uninterrupted. When the  rollover IRQ happens, the  left
  2287.      voice will be changed to loop at  the 20K position. At this point  the
  2288.      software will be able to load the  next 10K of left channel data  into
  2289.      the FIRST 10K of the left channel DRAM. The right channel is also sent
  2290.      10K of data into its FIRST 10K.
  2291. 14)  Now each channel  has the data  to play when  they loop  at their  20K
  2292.      marks.
  2293. 15)  When the left  channel's loop  IRQ happens,  both the  left and  right
  2294.      channel can be sent more data into their SECOND 10K buffer. Also,  the
  2295.      left channel's  looping will  be turned  off and  it will  be told  to
  2296.      rollover at its 10K mark again.  Now both channel's are ready to  play
  2297.      thru their 10K marks with no interruption.
  2298. 16)  Go back to step 13 and loop
  2299.  
  2300. The above algorithm does not detail the startup conditions or the  shutdown
  2301. conditions.
  2302.  
  2303. Things that you will need to accomodate are:
  2304.  
  2305. 1) Less than 1 buffer full of data.
  2306. 2) How to terminate when data ends in  first buffer. You must allow it  to
  2307.    loop back from the end and then stop at the end of the data  instead of
  2308.    rolling over at the middle. Both right and left must be taken care of.
  2309. 3) How to terminate when data ends in the second buffer.  After filling in
  2310.    the data in the second buffer, you can turn off the rolling over at the
  2311.    middle and tell it to stop at the end of the data in the second buffer.
  2312.  
  2313. Be sure you understand all the starting and ending possibilties when coding
  2314. you application.
  2315.  
  2316. The basic idea is to let the right voice  loop forever on a buffer of  data
  2317. and feed it data  based on IRQ  generated from the  left channel. The  left
  2318. channel can be monitored  via the rollover feature  to generate and IRQ  at
  2319. the halfway point and an IRQ at the loop point at the end of the buffer  to
  2320. know when the second buffer finishes. Data will then be sent to BOTH voices
  2321. for the portion of data that it just finished playing.
  2322.  
  2323.  
  2324. Hardware Control
  2325. ================
  2326.  
  2327. This method has  the advantage  of not  needing to  de-interleave the  data
  2328. before DMAing it into  UltraSound DRAM: the data  is  sent  to DRAM in  the
  2329. interleaved format. This  means that  a voice must  be able  to play  every
  2330. other sample  to correctly  separate  the right  and  left channel.  It  is
  2331. possible to set up the GF1  and the 2 voices to  do this, however, it  will
  2332. only work for 2 usable freqencies. (44100 and 22050). Any other frequencies
  2333. must be done using the software control de-interleaving method.
  2334.  
  2335.  
  2336.  
  2337.  
  2338. ___________________________________________________________________________
  2339.                                                                          34
  2340.  
  2341.  
  2342.  
  2343. Ultrasound Software Development Kit (SDK)                      Version 2.10
  2344. ___________________________________________________________________________
  2345.  
  2346. The theory behind how to achieve  this is quite complex. It involves  using
  2347. the # of active voices and the voice's frequency control register to get it
  2348. to grab the correct  samples at the  proper frequency.   Here is the  setup
  2349. necessary to playback 44100 Hz stereo and 22050 Hz stereo data:
  2350.  
  2351. 44100 Hz:Set the #  of active voices  to 14 and  set both voices  playback
  2352.          rate to 88200 hz.
  2353.  
  2354. 22050 Hz:Set the #  of active voices  to 28 and  set both voices  playback
  2355.          rate to 44100 hz
  2356.  
  2357. These two configurations  will make both  voices have  a frequency  control
  2358. register equal to 2. The frequency control register holds the amount  added
  2359. to the current voice playback location to get the next playback location.
  2360.  
  2361. Normally, this number is  a fraction so interpolation  is done to  generate
  2362. intermediate points between successive locations. With interleaved data, we
  2363. don't want to interpolate since the  neighboring data points belong to  the
  2364. other channel.  We want to completely skip over the point after the current
  2365. one, and go to our current position plus 2.
  2366.  
  2367. The number of active  voices selected will determine  the update rate.  The
  2368. more voices that are active, the longer time between updates, thus  slowing
  2369. down the frequency.  14 active voices  will give and  update rate of  about
  2370. 22.5 microseconds (44100 hz), whereas 28  voices will give and update  rate
  2371. of about 45 microseconds (22050 hz).
  2372.  
  2373. The intialization of the voices in  this mode will obviously be  different.
  2374. Essenntially, the voices must be  set up to play  the same data but  offset
  2375. their start and end points by one or two bytes, depending on whether it  is
  2376. an 8- or 16-bit sample.
  2377.  
  2378.  
  2379. 3.12 C-specific information
  2380.  
  2381. Currently,  10  different  C   memory  model/compiler  configurations   are
  2382. supplied.  Large, medium, small and  tiny models for Borland and  Microsoft
  2383. compilers are available,  as well  as flat  model for  WatCom and  MetaWare
  2384. compilers.  The level  0 library contains the  lowest level function  calls
  2385. that talk directly to the hardware.  The level 1 library is a little higher
  2386. and contains  functions that  call level  0 functions.   The  3D  libraries
  2387. contain the functions necessary for implementing the Focal Point 3D sounds.
  2388. Borland C++ 2.0  and 3.1, Microsoft  C 6.0, Watcom  C9.0/386, and  Metaware
  2389. High C/C++ were used to  test the library routines.   These are the  naming
  2390. conventions for the C libraries:
  2391.  
  2392.      ultra0lb.lib Level 0, large model,  Borland C
  2393.      ultra1lb.lib Level 1, large model,  Borland C
  2394.      ult3D_lb.lib      3D, large model,  Borland C
  2395.  
  2396.      ultra0mb.lib Level 0, medium model, Borland C
  2397.      ultra1mb.lib Level 1, medium model, Borland C
  2398.      ult3D_mb.lib      3D, medium model, Borland C
  2399.  
  2400.  
  2401. ___________________________________________________________________________
  2402.                                                                          35
  2403.  
  2404.  
  2405.  
  2406. Ultrasound Software Development Kit (SDK)                      Version 2.10
  2407. ___________________________________________________________________________
  2408.  
  2409.      ultra0sb.lib Level 0, small model,  Borland C
  2410.      ultra1sb.lib Level 1, small model,  Borland C
  2411.      ult3D_sb.lib      3D, small model,  Borland C
  2412.  
  2413.      ultra0tb.lib Level 0, tiny model,   Borland C
  2414.      ultra1tb.lib Level 1, tiny model,   Borland C
  2415.      ult3D_tb.lib      3D, tiny model,   Borland C
  2416.  
  2417.      ultra0lm.lib Level 0, large model,  Microsoft C
  2418.      ultra1lm.lib Level 1, large model,  Microsoft C
  2419.      ult3D_lm.lib      3D, large model,  Microsoft C
  2420.  
  2421.      ultra0mm.lib Level 0, medium model, Microsoft C
  2422.      ultra1mm.lib Level 1, medium model, Microsoft C
  2423.      ult3D_mm.lib      3D, medium model, Microsoft C
  2424.  
  2425.      ultra0sm.lib Level 0, small model,  Microsoft C
  2426.      ultra1sm.lib Level 1, small model,  Microsoft C
  2427.      ult3D_sm.lib      3D, small model,  Microsoft C
  2428.  
  2429.      ultra0tm.lib Level 0, tiny model,   Microsoft C
  2430.      ultra1tm.lib Level 1, tiny model,   Microsoft C
  2431.      ult3D_tm.lib      3D, tiny model,   Microsoft C
  2432.  
  2433.      ultra0wc.lib Level 0, Flat model,   Watcom C
  2434.      ultra1wc.lib Level 1, Flat model,   Watcom C
  2435.      ult3D_wc.lib      3D, Flat model,   Watcom C
  2436.  
  2437.      ultra0mw.lib Level 0, Flat model,   Metaware High C/C++
  2438.      ultra1mw.lib Level 1, Flat model,   Metaware High C/C++
  2439.      ult3D_mw.lib      3D, Flat model,   Metaware High C/C++
  2440.  
  2441. Several example applications are supplied on the toolkit disks to show  you
  2442. how to interface to the libraries.   Please look them over carefully.  They
  2443. are the best way to get a handle on the way the card operates.
  2444.  
  2445.  
  2446.  
  2447. 3.13 PASCAL-specific information
  2448.  
  2449. Version 2.10 of  the UltraSound  SDK is the  first version  which has  full
  2450. support for Turbo Pascal 6.0  and 7.0, as well  as Borland Pascal 7.0.  For
  2451. those of  you who  are  curious, Borland  Pascal  7.0 is  the  professional
  2452. version of Turbo Pascal 7.0.   It costs more, but  includes a lot of  bells
  2453. and whistles that are not included in the regular 'Turbo' version (for more
  2454. information, contact Borland).
  2455.  
  2456. The translation was done  entirely by Kurt  Kennett of Ingenuity  Software,
  2457. and is a  direct translation of  the C toolkit.   The code  was written  in
  2458. Borland Pascal 7 and  then minor adjustments were  made to make it  compile
  2459. under Turbo 6 and 7.
  2460.  
  2461.  
  2462.  
  2463.  
  2464. ___________________________________________________________________________
  2465.                                                                          36
  2466.  
  2467.  
  2468.  
  2469. Ultrasound Software Development Kit (SDK)                      Version 2.10
  2470. ___________________________________________________________________________
  2471.  
  2472. Due to the fact that the Pascal translation  was done after the C code  was
  2473. finished, some of  the naming  conventions for  some of  the functions  and
  2474. record types reflects  a 'C-like'  syntax and  style.   Some conversion  of
  2475. function  result  types  has  been  done  to  reflect  a  more  Pascal-like
  2476. structure.
  2477.  
  2478. After installation of the  SDK, there will be  two units and one  interface
  2479. file available in the PASCAL subdirectory:
  2480.  
  2481.      ULTRADRV.V60  Turbo Pascal 6.0 version
  2482.      ULTRADRV.V70  Turbo/Borland Pascal 7.0 version
  2483.      ULTRADRV.INT  This is the interface section for all units.
  2484.  
  2485. You should copy the unit you wish to  use to one of your unit  directories,
  2486. and then rename the unit to  'ULTRADRV.TPU'.  You may experience  compiling
  2487. problems if you  do not rename  the file.   You may also  wish to copy  the
  2488. interface file to use as a quick-reference.
  2489.  
  2490. For users of Turbo and Borland Pascal 7.0, a help file has been provided to
  2491. allow quick context-sensitive  help from inside  the IDE editor.   Also,  a
  2492. MAKEHELP.TXT version of this  help file has been  provided for those  users
  2493. who employ TurboPower's context-sensitive help system.
  2494.  
  2495. To install the IDE help file, load Turbo or Borland Pascal 7 and select the
  2496. 'Help' menu from the  menu bar.  Choose  the 'Files...' option, and  select
  2497. the 'Add'  button.   Choose the  file  'ULTRADRV.TPH' from  the  UltraSound
  2498. PASCAL subdirectory.  After you have done this, you may use the F1 key  and
  2499. it's derivatives to access reference information  for any of the  functions
  2500. and procedures in the SDK reference manual (chapter 3).
  2501.  
  2502. For  example,   after   installing   the   help   file,   type   the   word
  2503. 'UltraSetFrequency' into the IDE, move the  cursor on top of the word,  and
  2504. press CTRL-F1.  You will be given an explanation of the syntax and usage of
  2505. the Procedure, as  well as  information on  related procedures,  functions,
  2506. constants, and variables.
  2507.  
  2508. A short section  detailing specific information  about types and  constants
  2509. available follows.   For more information,  please see  the interface  file
  2510. ULTRADRV.INT.
  2511.  
  2512.  
  2513.  
  2514. 3.13.1 Available constants and variables
  2515.  
  2516. The SDK TPU (or  'driver') has some predefined  constants to assist you  in
  2517. programming  various  aspects  of  the  card.    There  are  three   common
  2518. frequencies that sampled sounds are played at: 11, 22, and 44 KHz:
  2519.  
  2520.      Khz_11 = 11025;
  2521.      Khz_22 = 22050;
  2522.      Khz_44 = 44100;
  2523.  
  2524.  
  2525.  
  2526.  
  2527. ___________________________________________________________________________
  2528.                                                                          37
  2529.  
  2530.  
  2531.  
  2532. Ultrasound Software Development Kit (SDK)                      Version 2.10
  2533. ___________________________________________________________________________
  2534.  
  2535. Whenever volume is specified, there is a volume control byte.  The bits  in
  2536. this byte control several important functions.  OR the following  constants
  2537. together with zero if you need  them.  If you  don't, just specify zero  as
  2538. the volume control byte:
  2539.  
  2540.      Loop_Volume           = 08;
  2541.      Bi_Directional_Volume = 16;
  2542.      Enable_Volume_Handler = 32;
  2543.  
  2544. Whenever a voice is started or changed, there is a voice control byte.  The
  2545. bits in this byte control several  important functions for each voice.   OR
  2546. the following constants together with zero if you need them.  If you don't,
  2547. just specify zero as the voice control byte:
  2548.  
  2549.    Voice_Data_16Bit        = 04;
  2550.    Loop_Voice              = 08;
  2551.    Bi_Directional_Voice    = 16;
  2552.    Enable_VoiceEnd_Handler = 32;
  2553.  
  2554. When a DMA transfer is  started, you need to  tell the DMA controller  what
  2555. type of  data  you  are sending  to  the  UltraSound, as  well  as  if  the
  2556. controller should  convert  the  data  to  2's  complement.    If  you  are
  2557. downloading ram .SND  files to the  card, you need  to OR the  Convert_Data
  2558. constant to 0 as the control byte.  If you are downloading 16 Bit data, you
  2559. need to OR the control byte with DMA_Data_16Bit.
  2560.  
  2561.    DMA_Data_16Bit = 64;
  2562.    Convert_Data   = 128;
  2563.  
  2564. There are several predefined  variables to help  you manage the  UltraSound
  2565. card as you  use it.   These variables determine  the Configuration,  error
  2566. codes, and whether or not the card is installed:
  2567.  
  2568. Ultra_Installed : BOOLEAN;
  2569. If the driver cannot  read the environment variable  'ULTRASND' when it  is
  2570. initialized (i.e.  when  your program  starts),  this BOOLEAN  will  remain
  2571. false.  Otherwise,  the variable Ultra_Config  (see below) will  be set  up
  2572. with the values found in the environment variable.
  2573.  
  2574. Ultra_Config  : Ultra_CFG;
  2575. If the  driver  was  able  to read  a  configuration  from  the  'ULTRASND'
  2576. environment variable,  this variable  record will  be  filled in  with  the
  2577. appropriate information  found  in the  environment.   If  the  environment
  2578. string is not  found, this variable  will assume  a default  configuration.
  2579. All of the functions and procedures in the driver use this configuration to
  2580. initialize and use the  card.  Be  careful if you're  going to go  sticking
  2581. values into this record.  The main use  of this variable is to display  the
  2582. active configuration to the user.
  2583.  
  2584.  
  2585.  
  2586.  
  2587.  
  2588.  
  2589.  
  2590. ___________________________________________________________________________
  2591.                                                                          38
  2592.  
  2593.  
  2594.  
  2595. Ultrasound Software Development Kit (SDK)                      Version 2.10
  2596. ___________________________________________________________________________
  2597.  
  2598. The driver predefines three variables to help you with error control:
  2599.  
  2600. UltraOk       : Boolean;
  2601. This boolean always maintains the status  of the last UltraSound  procedure
  2602. or function.  If there was a  problem with the routine, this variable  will
  2603. be FALSE.  Otherwise, it will be TRUE (indicating no error).
  2604.  
  2605. UltraError    : Integer;
  2606. This is the "Error  Code" of the Error.   This variable is  set to 0 if  no
  2607. error has occurred, and is only set when UltraOk becomes FALSE.
  2608.  
  2609. UltraErrorStr : String;
  2610. This is the "description"  of the error  which has occurred.   As an  added
  2611. bonus to you, the programmer, this string is set with a (descriptive) error
  2612. message whenever a card-related error occurs.
  2613.  
  2614.  
  2615.  
  2616. 3.13.2 Examples
  2617.  
  2618. There are several example programs included with the units described in the
  2619. previous section:
  2620.  
  2621. GUSINIT.PAS
  2622. This example file is a small  unit that you may  want to use to  initialize
  2623. the GUS before you use it.  The important thing about this unit is that  it
  2624. installs an  'Exit  Procedure' which  is  called upon  program  termination
  2625. (normal or crash-out).   The  exit procedure  closes down  the card  before
  2626. returning to DOS (or the IDE, depending upon where you are).  In TP and  BP
  2627. 7, you can type 'ExitProc' into the IDE, move the cursor on top of it,  and
  2628. hit CTRL-F1 for a detailed explanation of what an exit procedure is.  After
  2629. including this unit in  your 'uses' clause, your  main program can just  go
  2630. ahead and start using it.  You don't need to call UltraOpen, UltraReset, or
  2631. even UltraClose when you're finished.
  2632.  
  2633. GUS1.PAS
  2634. This is the primitive example program for the card which loads three sounds
  2635. (a laser blast, a photon  torpedo, and a missile)  into the card's RAM  and
  2636. then allows you to press the '1'..'3' keys to play them.  This example uses
  2637. the GUSINIT unit - showing you how easy it is to use.
  2638.  
  2639. LOADMOD.PAS
  2640. This is a unit which provides services to load Amiga '.MOD' files into  GUS
  2641. RAM and main memory.  After calling  a single function, the file will  have
  2642. been loaded and the samples contained in it set up to play.  It is left  up
  2643. to you to supply playback routines or trivial sample-playing routines.
  2644.  
  2645.  
  2646.  
  2647.  
  2648.  
  2649.  
  2650.  
  2651.  
  2652.  
  2653. ___________________________________________________________________________
  2654.                                                                          39
  2655.  
  2656.  
  2657.  
  2658. Ultrasound Software Development Kit (SDK)                      Version 2.10
  2659. ___________________________________________________________________________
  2660.  
  2661. 3.13.3 Management of GUS RAM.
  2662.  
  2663. The Pascal  version of  the  SDK employs  a  different approach  to  memory
  2664. control than the C toolkit.  In the C SDK, a small amount of the GUS RAM is
  2665. used to keep track of allocated  blocks.  In the  Pascal SDK, a very  small
  2666. amount of heap space is used to keep track of the blocks.
  2667.  
  2668. Because of the way  the UltraSound RAM is  structured, any particular  card
  2669. has a total  amount of installed  RAM that is  a multiple of  256k.   Since
  2670. samples cannot be played across these  boundaries, the driver unit  divides
  2671. the total RAM by 256k into 1 to 4 'pools'.
  2672.  
  2673.         |--------------------------------------|
  2674.         |                                      | 256k (a single 'pool')
  2675.         |--------------------------------------|
  2676.  
  2677. Each of these pools is seen as a single unit which can be subdivided.   For
  2678. the purposes of this example, we will  use a GUS which has 512k  installed.
  2679. If this is the case, there will be two pools of RAM available:
  2680.  
  2681.         |--------------------------------------|
  2682.         |                                      | Pool 1
  2683.         |--------------------------------------|
  2684.         |                                      | Pool 2
  2685.         |--------------------------------------|
  2686.  
  2687. Once the card has been  initialized, there will be  a small amount of  heap
  2688. space being  used to  keep track  of  these pools  (usually less  than  100
  2689. bytes).  At this point, the  UltraMaxFree function will return 256k,  since
  2690. the size of the  largest block that  can be allocated  is one entire  pool.
  2691. The UlraMemAvail function  will return 512k  however, reflecting the  total
  2692. amount of memory still available.
  2693.  
  2694. If a user were to allocate a 128k chunk of memory, the allocation  routines
  2695. would look in each pool sequentially until a pool is found with enough room
  2696. for the new block.  At this point in our example, it would use Pool 1.
  2697.  
  2698.         |----------------------------------------|
  2699.         |XXXXXXXXXXXXXXXXXXXX                    | Pool 1
  2700.         |----------------------------------------|
  2701.         |                                        | Pool 2
  2702.         |----------------------------------------|
  2703.  
  2704. The X's in the diagram above reflect used space.  If the size of the  block
  2705. being allocated is not  divisible by 32,  the actual size  of the block  in
  2706. memory is increased to the next multiple of 32.  For example, if I were  to
  2707. ask for a 50  byte chunk of  RAM, the actual  size of ram  that I would  be
  2708. using would be  64 bytes in  size.  This  is so that  all memory  locations
  2709. returned will  be  aligned on  a  32-byte boundary.    At this  point,  the
  2710. UltraMaxFree function will return 256k, since the size of the largest block
  2711. that can be allocated is still one entire pool (Pool 2).  The UltraMemAvail
  2712. function will  return 384k,  reflecting the  total amount  of memory  still
  2713. available.
  2714.  
  2715.  
  2716. ___________________________________________________________________________
  2717.                                                                          40
  2718.  
  2719.  
  2720.  
  2721. Ultrasound Software Development Kit (SDK)                      Version 2.10
  2722. ___________________________________________________________________________
  2723.  
  2724. If a user  were to  now allocate  a 200k  chunk of  memory, the  allocation
  2725. routines would once again  look in each pool  sequentially until a pool  is
  2726. found with enough room for the new block.  At this point in our example, it
  2727. would have to use Pool 2, since there is not enough room left in Pool 1.
  2728.  
  2729.         |----------------------------------------|
  2730.         |XXXXXXXXXXXXXXXXXXXX                    | Pool 1
  2731.         |----------------------------------------|
  2732.         |YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY         | Pool 2
  2733.         |----------------------------------------|
  2734.  
  2735. At this  point, the  UltraMaxFree function  would  return 128k,  since  the
  2736. largest block free is in Pool 1.   UltraMemFree would now return 184k.   If
  2737. we were to allocate a third block of 70k, the diagram would look like:
  2738.  
  2739.         |----------------------------------------|
  2740.         |XXXXXXXXXXXXXXXXXXXXZZZZZZZZZZ          | Pool 1
  2741.         |----------------------------------------|
  2742.         |YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY         | Pool 2
  2743.         |----------------------------------------|
  2744.  
  2745. If we were to now DEallocate the first  block (the X's in the diagram),  we
  2746. would be left  with a 'hole'  in the ram.   This is  reminiscent of a  hard
  2747. disk's free space fragmentation.
  2748.  
  2749.         |----------------------------------------|
  2750.         |                    ZZZZZZZZZZ          | Pool 1
  2751.         |----------------------------------------|
  2752.         |YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY         | Pool 2
  2753.         |----------------------------------------|
  2754.  
  2755. Note that the SDK's memory allocation  routines do NOT relocate samples  to
  2756. fend off fragmentation.  Note also that the memory routines are set up  and
  2757. are ready to be  used as soon as  you call UltraOpen,  and are closed  down
  2758. automatically (and  the heap  space they  use  deallocated) when  you  call
  2759. UltraClose.
  2760.  
  2761.  
  2762.  
  2763. 3.14 Coming Attractions
  2764.  
  2765. There are a couple of addendums  to the SDK that  will be released as  they
  2766. are completed.  They  deal with hardware  that is in  the process of  being
  2767. implemented.  Code and documentation necessary to make them operate will be
  2768. made available as soon as possible.
  2769.  
  2770. 1) New mixer.  All UltraSounds  that are made  that have  a board  revision
  2771. number greater than  3.6 will  incorporate a  new mixer.   Basically,  this
  2772. mixer allows  software control  over the  levels of  the input  and  output
  2773. signals.  This is a 1 chip mixer: Gravis will make specs and block diagrams
  2774. available as soon as we can.
  2775.  
  2776.  
  2777.  
  2778.  
  2779. ___________________________________________________________________________
  2780.                                                                          41
  2781.  
  2782.  
  2783.  
  2784. Ultrasound Software Development Kit (SDK)                      Version 2.10
  2785. ___________________________________________________________________________
  2786.  
  2787. 2) 16 bit recording  support. This falls into  2 categories: daughter  card
  2788. support and UltraMax  support.  Both  of these use  the same chip  (Crystal
  2789. Semiconductors CS4231 CODEC).   Contact  Crystal to  get a  data sheet  for
  2790. specs on how to program it:  their telephone number is (512) 445-7222.  The
  2791. only difference in the 16 bit recording  capabilities of the 2 cards is  in
  2792. how it interfaces to the rest of  the UltraSound card.  Block diagrams  for
  2793. both of these boards will be made available when the toolkit for the  codec
  2794. is released.
  2795.  
  2796.  
  2797.  
  2798. 3.15 Technical Support
  2799.  
  2800.                 Questions regarding the SDK can be sent to:
  2801.  
  2802.                            SDK Technical Support
  2803.                               Advanced Gravis
  2804.                          101-3750 North Fraser Way
  2805.                      Burnaby, British Columbia V5J 5E9
  2806.                             FAX (604) 431-5155
  2807.  
  2808.       If you have access to a modem, you can contact Gravis' BBS at:
  2809.                               (604) 431-5927
  2810.  
  2811.     If you have access to internet mail services, you can send mail to
  2812. 'john.smith@gravis.com' for general questions, or 'kurt.kennett@gravis.com'
  2813.           for questions regarding the Pascal version of the SDK.
  2814.  
  2815.  Please make sure you have consulted this documentation before contacting
  2816.                         Technical support. (RTFM!)
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828.  
  2829.  
  2830.  
  2831.  
  2832.  
  2833.  
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842. ___________________________________________________________________________
  2843.                                                                          42
  2844.  
  2845.  
  2846.  
  2847. Ultrasound Software Development Kit (SDK)                      Version 2.10
  2848. ___________________________________________________________________________
  2849.  
  2850.                         Chapter 4 - Reference Guide
  2851.  
  2852. This chapter is a reference guide for the routines that compromise both the
  2853. C and Pascal versions of the SDK.  Please see the table of contents to look
  2854. up a particular routine quickly by name.
  2855.  
  2856.  
  2857. UltraCalcRate
  2858. _________________________________
  2859.  
  2860. Purpose:   To calculate the rate for a volume ramp.
  2861.  
  2862. C:         unsigned char UltraCalcRate(start,end,mil_secs);
  2863.            unsigned int start;
  2864.            unsigned int end;
  2865.            unsigned long mil_secs;
  2866.  
  2867. PASCAL:    FUNCTION UltraCalcRate(StartV   : WORD;
  2868.                                   EndV     : WORD;
  2869.                                   Mil_Secs : LONGINT) : BYTE;
  2870.  
  2871. Remarks:   This routine calculates the  rate necessary to  ramp the volume
  2872.            from StartV volume  (logarithmic) to  EndV volume (logarithmic)
  2873.            in a desired # of milliseconds.  This value should be passed to
  2874.            UltraRampVolume.  This  is only  an approximation.   The longer
  2875.            the time span, the less precise the result is likely to be.
  2876.  
  2877. Returns:   A  value   which   can   be   passed   to  UltraRampVolume   or
  2878.            UltraRampLinearVolume.
  2879.  
  2880. See also:  UltraRampVolume, UltraRampLinearVolume
  2881.  
  2882.  
  2883.  
  2884. UltraClose
  2885. _________________________________
  2886.  
  2887. Purpose:   To close out the UltraSound card.
  2888.  
  2889. C:         int UltraClose(void);
  2890.  
  2891. PASCAL:    FUNCTION UltraClose : BOOLEAN;
  2892.  
  2893. Remarks:   This routine should  be called  before your  application exits.
  2894.            It shuts down all  audio and puts  the card in  a stable state.
  2895.            It also puts  the PC back  to the  state prior  to running your
  2896.            application (resets interrupt vectors etc).
  2897.  
  2898. Returns:   TRUE if Close was successful, FALSE otherwise.
  2899.  
  2900. See also:  UltraOpen, UltraReset
  2901.  
  2902.  
  2903.  
  2904.  
  2905. ___________________________________________________________________________
  2906.                                                                          43
  2907.  
  2908.  
  2909.  
  2910. Ultrasound Software Development Kit (SDK)                      Version 2.10
  2911. ___________________________________________________________________________
  2912.  
  2913. UltraDownload
  2914. _________________________________
  2915.  
  2916. Purpose:   Download a chunk of data into UltraSound DRAM.
  2917.  
  2918. C:         int UltraDownload(dataptr,control,dram_loc,len,wait);
  2919.            void *dataptr;
  2920.            unsigned char control;
  2921.            unsigned long dram_loc;
  2922.            unsigned int len;
  2923.            int wait;
  2924.  
  2925. PASCAL:    FUNCTION UltraDownLoad(DataPtr  : POINTER;
  2926.                                   Control  : BYTE;
  2927.                                   DRAM_Loc : LONGINT;
  2928.                                   Len      : WORD;
  2929.                                   Wait     : BOOLEAN) : BOOLEAN;
  2930.  
  2931. Remarks:   This routine will transfer a chunk of data from the PC's RAM to
  2932.            the UltraSound's DRAM.  It will  transfer 'Len' # of bytes from
  2933.            DataPtr (in  PC) to  DRAM_Loc (in  UltraSound).   If  'Wait' is
  2934.            TRUE, then it  will wait  until the transfer  is complete.   If
  2935.            'Wait' is FALSE, it will return as soon as transfer is started.
  2936.            In some cases  where you  need to get  output quickly,  you can
  2937.            start the download and  then immediately start  a voice playing
  2938.            the data.   The  DMA transfer  is  MUCH faster  than  the voice
  2939.            playback, so  it will  be able  to download  data ahead  of the
  2940.            playback.  For obvious reasons, this  will not work if you want
  2941.            to play the data backwards.  See Appendix D for a definition of
  2942.            the control  bits.    They  specify  the  type  of  data  being
  2943.            transferred.
  2944.  
  2945. Returns:   C:      ULTRA_OK if no problem.
  2946.                    DMA_BUSY if DMA Channel is busy.
  2947.  
  2948.            PASCAL: TRUE if transfer was successful.   FALSE otherwise.
  2949.                    If unsuccessful, check UltraErrorStr for the reason.
  2950.  
  2951. See also:  UltraUpload, UltraDRAMDMABusy
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968. ___________________________________________________________________________
  2969.                                                                          44
  2970.  
  2971.  
  2972.  
  2973. Ultrasound Software Development Kit (SDK)                      Version 2.10
  2974. ___________________________________________________________________________
  2975.  
  2976. UltraDRAMDMABusy
  2977. _________________________________
  2978.  
  2979. Purpose:   Test to see if the DMA channel is busy.
  2980.  
  2981. C:         int UltraDramDMABusy(void);
  2982.  
  2983. PASCAL:    FUNCTION UltraDRAMDMABusy : BOOLEAN;
  2984.  
  2985. Remarks:   This routine will check to see  if the to/from DRAM DMA channel
  2986.            is busy.  It  might be useful so  your application doesn't hang
  2987.            around while waiting for a DMA transfer to complete.
  2988.  
  2989. Returns:   TRUE if the channel is still busy.   FALSE if it's free.
  2990.  
  2991. See also:  UltraWaitDRAMDMA, UltraDownload, UltraUpload
  2992.  
  2993.  
  2994.  
  2995. UltraGoRecord
  2996. _________________________________
  2997.  
  2998. Purpose:   To start up a pre-set record.
  2999.  
  3000. C:         int UltraGoRecord(control);
  3001.            unsigned char control;
  3002.  
  3003. PASCAL:    FUNCTION UltraGoRecord(Control : BYTE) : BOOLEAN;
  3004.  
  3005. Remarks:   This routine  will  start  up a  pre-primed  record  (done with
  3006.            UltraPrimeRecord).  It can also be used to restart a indefinite
  3007.            recording process from the recording handler callback.
  3008.  
  3009. Returns:   C:      ULTRA_OK if no error
  3010.                    DMA_BUSY if the channel is busy
  3011.  
  3012.            PASCAL: TRUE if Record started ok.  FALSE otherwise.
  3013.                    If FALSE check the UltraErrorStr for the reason.
  3014.  
  3015. See also:  UltraRecordData, UltraPrimeRecord, UltraRecordHandler
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.  
  3023.  
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030.  
  3031. ___________________________________________________________________________
  3032.                                                                          45
  3033.  
  3034.  
  3035.  
  3036. Ultrasound Software Development Kit (SDK)                      Version 2.10
  3037. ___________________________________________________________________________
  3038.  
  3039. UltraGoVoice
  3040. _________________________________
  3041.  
  3042. Purpose:   To start a voice that has already been primed.
  3043.  
  3044. C:         void UltraGoVoice(voice,mode);
  3045.            int voice;
  3046.            unsigned char mode;
  3047.  
  3048. PASCAL:    PROCEDURE UltraGoVoice(Voice : INTEGER;
  3049.                                   VMode : BYTE);
  3050.  
  3051. Remarks:   This routine will start up a voice that has already been primed
  3052.            with set-up values by  UltraPrimeVoice.  This can  be useful if
  3053.            you  need  to  start  multiple  voices  as  close  together  as
  3054.            possible.  See Appendix C for the mode bit definitions.
  3055.  
  3056. See also:  UltraPrimeVoice, UltraStartVoice
  3057.  
  3058.  
  3059.  
  3060. UltraDisableLineIn
  3061. _________________________________
  3062.  
  3063. Purpose:   To disable line level input.
  3064.  
  3065. C:         void UltraDisableLineIn(void);
  3066.  
  3067. PASCAL:    PROCEDURE UltraDisableLineIn;
  3068.  
  3069. Remarks:   If line level input is enabled and output is enabled, the input
  3070.            is routed directly to the  output and audio will  be heard.  If
  3071.            this is not desired, use this to disable line in.
  3072.  
  3073. See also:  UltraEnableLineIn, UltraGetLineIn
  3074.  
  3075.  
  3076.  
  3077. UltraDisableMicIn
  3078. _________________________________
  3079.  
  3080. Purpose:   To disable microphone input.
  3081.  
  3082. C:         void UltraDisableMicIn(void);
  3083.  
  3084. PASCAL:    PROCEDURE UltraDisableMicIn;
  3085.  
  3086. Remarks:   If microphone input is enabled and output is enabled, the input
  3087.            is routed directly to the  output and audio will  be heard.  If
  3088.            this is not desired, use this to disable microphone in.
  3089.  
  3090. See also:  UltraEnableMicIn, UltraGetMicIn
  3091.  
  3092.  
  3093.  
  3094. ___________________________________________________________________________
  3095.                                                                          46
  3096.  
  3097.  
  3098.  
  3099. Ultrasound Software Development Kit (SDK)                      Version 2.10
  3100. ___________________________________________________________________________
  3101.  
  3102. UltraDisableOutput
  3103. _________________________________
  3104.  
  3105. Purpose:   To turn off all output from the UltraSound.
  3106.  
  3107. C:         void UltraDisableOutput(void);
  3108.  
  3109. PASCAL:    PROCEDURE UltraDisableOutput;
  3110.  
  3111. Remarks:   This routine will disable all output from the UltraSound.  This
  3112.            can be  used during  recording so  that the  input will  not be
  3113.            looped back to the output.  It is also useful to disable output
  3114.            during resets  since  that will  help  eliminate  'pops' during
  3115.            initialization.
  3116.  
  3117. See also:  UltraEnableOutput, UltraGetOutput
  3118.  
  3119.  
  3120.  
  3121. UltraEnableLineIn
  3122. _________________________________
  3123.  
  3124. Purpose:   To enable line level input.
  3125.  
  3126. C:         void UltraEnableLineIn(void);
  3127.  
  3128. PASCAL:    PROCEDURE UltraEnableLineIn;
  3129.  
  3130. Remarks:   Turns on the line level  input.  If you  are not recording from
  3131.            the line  input,  it is  probably  not desirable  to  have this
  3132.            enabled since it will  be looped back to  the output (if output
  3133.            is enabled).
  3134.  
  3135. See also:  UltraDisableLineIn, UltraGetLineIn
  3136.  
  3137.  
  3138.  
  3139. UltraEnableMicIn
  3140. _________________________________
  3141.  
  3142. Purpose:   To turn on the microphone input.
  3143.  
  3144. C:         void UltraEnableMicIn(void);
  3145.  
  3146. PASCAL:    PROCEDURE UltraEnableMicIn;
  3147.  
  3148. Remarks:   This routine should be called when  you want to record from the
  3149.            microphone.  It is  possible to have both  the microphone input
  3150.            enabled and line level input enabled.  If you are not recording
  3151.            from the  microphone, it  is recommended  that it  be disabled,
  3152.            since it will reduce noise on the output.
  3153.  
  3154. See also:  UltraDisableMicIn, UltraGetMicIn
  3155.  
  3156.  
  3157. ___________________________________________________________________________
  3158.                                                                          47
  3159.  
  3160.  
  3161.  
  3162. Ultrasound Software Development Kit (SDK)                      Version 2.10
  3163. ___________________________________________________________________________
  3164.  
  3165. UltraEnableOutput
  3166. _________________________________
  3167.  
  3168. Purpose:   To enable output from the UltraSound.
  3169.  
  3170. C:         void UltraEnableOutput(void);
  3171.  
  3172. PASCAL:    PROCEDURE UltraEnableOutput;
  3173.  
  3174. Remarks:   This routine  must  be called  to  enable any  output  from the
  3175.            UltraSound.  This can be used to turn on output after muting it
  3176.            with UltraDisableOutput.
  3177.  
  3178. See also:  UltraDisableOutput, UltraGetOutput
  3179.  
  3180.  
  3181.  
  3182. UltraGetLineIn
  3183. _________________________________
  3184.  
  3185. Purpose:   To return the current state of line level input
  3186.  
  3187. C:         int UltraGetLineIn(void);
  3188.  
  3189. PASCAL:    FUNCTION UltraGetLineIn : BOOLEAN;
  3190.  
  3191. Remarks:   This can be useful if you want to  change the state of the line
  3192.            level input and then restore it back to the original state.
  3193.  
  3194. Returns:   TRUE if LineIn is Enabled, FALSE otherwise.
  3195.  
  3196. See also:  UltraEnableLineIn, UltraDisableLineIn
  3197.  
  3198.  
  3199.  
  3200. UltraGetOutput
  3201. _________________________________
  3202.  
  3203. Purpose:   To return the current output enabled state.
  3204.  
  3205. C:         int UltraGetOutput(void);
  3206.  
  3207. PASCAL:    FUNCTION UltraGetOutput;
  3208.  
  3209. Remarks:   This can  be useful  if you  want to  change  the state  of the
  3210.            output and then restore it back to the original state.
  3211.  
  3212. Returns:   TRUE if Output is Enabled, FALSE otherwise.
  3213.  
  3214. See also:  UltraEnableOutput, UltraDisableOutput
  3215.  
  3216.  
  3217.  
  3218.  
  3219.  
  3220. ___________________________________________________________________________
  3221.                                                                          48
  3222.  
  3223.  
  3224.  
  3225. Ultrasound Software Development Kit (SDK)                      Version 2.10
  3226. ___________________________________________________________________________
  3227.  
  3228. UltraGetMicIn
  3229. _________________________________
  3230.  
  3231. Purpose:   To return the current state of the microphone input.
  3232.  
  3233. C:         int UltraGetMicIn(void);
  3234.  
  3235. PASCAL:    FUNCTION UltraGetMicIn;
  3236.  
  3237. Remarks:   This can  be useful  if you  want to  change  the state  of the
  3238.            microphone input  and  then  restore it  back  to  the original
  3239.            state.
  3240.  
  3241. Returns:   TRUE if Output is Enabled, FALSE otherwise.
  3242.  
  3243. See also:  UltraEnableMicIn, UltraDisableMicIn
  3244.  
  3245.  
  3246.  
  3247.  
  3248.  
  3249.  
  3250.  
  3251.  
  3252.  
  3253.  
  3254.  
  3255.  
  3256.  
  3257.  
  3258.  
  3259.  
  3260.  
  3261.  
  3262.  
  3263.  
  3264.  
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270.  
  3271.  
  3272.  
  3273.  
  3274.  
  3275.  
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283. ___________________________________________________________________________
  3284.                                                                          49
  3285.  
  3286.  
  3287.  
  3288. Ultrasound Software Development Kit (SDK)                      Version 2.10
  3289. ___________________________________________________________________________
  3290.  
  3291. UltraDRAMTcHandler
  3292. _________________________________
  3293.  
  3294. Purpose:   To define a callback for a DMA transfer completion.
  3295.  
  3296. C:         PFV *(UltraDramTcHandler(handler));
  3297.            PFV *handler;
  3298.  
  3299. PASCAL:    PROCEDURE UltraDRAMTcHandler(VAR Handler : PFV);
  3300.  
  3301. Remarks:   This procedure defines a  callback for whenever  a DMA transfer
  3302.            to the  UltraSound has  been  completed.   The  routine address
  3303.            passed as a parameter is set as the new handler.  No parameters
  3304.            are passed to your new handler.
  3305.  
  3306. Returns:   For C  users,  this  routine returns  the  address  of  the old
  3307.            handler.
  3308.  
  3309. PASCAL
  3310. Example:   Since PASCAL cannot  return function  or procedure  type values
  3311.            from  functions,  the  equivalent  routine   was  made  into  a
  3312.            procedure which took  a single VAR  parameter.   Thus, when you
  3313.            are going to change the address  of a callback routine, you put
  3314.            the new address into a variable,  run it through the procedure,
  3315.            and what will then be in the variable is the address of the old
  3316.            handler:
  3317.  
  3318.            VAR
  3319.              OldProc : PFV;
  3320.  
  3321.            Procedure MyNewProc;
  3322.              { The new handler - defined as a normal procedure }
  3323.              begin
  3324.                ...
  3325.              end;
  3326.  
  3327.            ...
  3328.            { Set OldProc to address of new handler }
  3329.            OldProc := MyNewProc;
  3330.            { Now set the new handler and return the old one }
  3331.            UltraDRAMTcHandler(OldProc);
  3332.            ...
  3333.  
  3334.            At this point,  OldProc holds the  address of  the old routine.
  3335.            Therefore, to chain to  the old routine, you  would simply have
  3336.            to call OldProc from your handler.
  3337.  
  3338.  
  3339.  
  3340.  
  3341.  
  3342.  
  3343.  
  3344.  
  3345.  
  3346. ___________________________________________________________________________
  3347.                                                                          50
  3348.  
  3349.  
  3350.  
  3351. Ultrasound Software Development Kit (SDK)                      Version 2.10
  3352. ___________________________________________________________________________
  3353.  
  3354. UltraMIDIXmitHandler
  3355. _________________________________
  3356.  
  3357. Purpose:   To define a callback for MIDI transmit interrupt.
  3358.  
  3359. C:         PFV *(UltraMIDIXmitHandler(handler));
  3360.            PFV *handler;
  3361.  
  3362. PASCAL:    PROCEDURE UltraMIDIXMitHandler(VAR Handler : WORD_PROC);
  3363.  
  3364. Remarks:   This procedure defines a callback for  whenever a MIDI transmit
  3365.            empty interrupt occurs.  This can be used to send out MIDI data
  3366.            under interrupt  control.    The routine  address  passed  as a
  3367.            parameter is set as the  new handler.  The  MIDI Status Byte is
  3368.            passed to the new handler defined.
  3369.  
  3370. Returns:   For C  users,  this  routine returns  the  address  of  the old
  3371.            handler.
  3372.  
  3373. PASCAL
  3374. Example:   See the example for UltraDRAMTcHandler.
  3375.  
  3376. See also:  UltraMIDIRecvHandler
  3377.  
  3378.  
  3379.  
  3380. UltraMIDIRecvHandler
  3381. _________________________________
  3382.  
  3383. Purpose:   To define a callback for a MIDI receive interrupt.
  3384.  
  3385. C:         PFV *(UltraMIDIRecvHandler(handler));
  3386.            PFV *handler;
  3387.  
  3388. PASCAL:    PROCEDURE UltraMIDIRecvHandler(VAR Handler : TWOWORD_PROC);
  3389.  
  3390. Remarks:   This procedure  defines  a  callback  for  whenever  a byte  is
  3391.            received in the MIDI input port.  This  can be used to get data
  3392.            from the MIDI port under interrupt contol.  The routine address
  3393.            passed as a parameter is set as the new handler.  The MIDI port
  3394.            status and MIDI  data are passed  to your handler.   The status
  3395.            bits are defined in Appendix D.
  3396.  
  3397. Returns:   For C  users,  this  routine returns  the  address  of  the old
  3398.            handler.
  3399.  
  3400. PASCAL
  3401. Example:   See the example for UltraDRAMTcHandler.
  3402.  
  3403. See also:  UltraMIDIXmitHandler
  3404.  
  3405.  
  3406.  
  3407.  
  3408.  
  3409. ___________________________________________________________________________
  3410.                                                                          51
  3411.  
  3412.  
  3413.  
  3414. Ultrasound Software Development Kit (SDK)                      Version 2.10
  3415. ___________________________________________________________________________
  3416.  
  3417. UltraTimer1Handler
  3418. _________________________________
  3419.  
  3420. Purpose:   To define a callback from Timer #1.
  3421.  
  3422. C:         PFV *(UltraTimer1Handler(handler));
  3423.            PFV *handler;
  3424.  
  3425. PASCAL:    PROCEDURE UltraTimer1Handler(VAR Handler : PFV);
  3426.  
  3427. Remarks:   This procedure defines a callback for whenever the UltraSound's
  3428.            Timer 1 'Ticks'.  The routine  address passed as a parameter is
  3429.            set as  the new  handler.   No  parameters are  passed  to this
  3430.            handler.
  3431.  
  3432. Returns:   For C  users,  this  routine returns  the  address  of  the old
  3433.            handler.
  3434.  
  3435. PASCAL
  3436. Example:   See the example for UltraDRAMTcHandler.
  3437.  
  3438. See also:  UltraTimer2Handler, UltraStartTimer
  3439.  
  3440.  
  3441.  
  3442. UltraTimer2Handler
  3443. _________________________________
  3444.  
  3445. Purpose:   To define a callback for Timer #2.
  3446.  
  3447. C:         PFV *(UltraTimer2Handler(handler));
  3448.            PFV *handler;
  3449.  
  3450. PASCAL:    PROCEDURE UltraTimer2Handler(VAR Handler : PFV);
  3451.  
  3452. Remarks:   This procedure defines a callback for whenever the UltraSound's
  3453.            Timer 2 'Ticks'.  The routine  address passed as a parameter is
  3454.            set as  the new  handler.   No  parameters are  passed  to this
  3455.            handler.
  3456.  
  3457. Returns:   For C  users,  this  routine returns  the  address  of  the old
  3458.            handler.
  3459.  
  3460. PASCAL
  3461. Example:   See the example for UltraDRAMTcHandler.
  3462.  
  3463. See also:  UltraTimer1Handler, UltraStartTimer
  3464.  
  3465.  
  3466.  
  3467.  
  3468.  
  3469.  
  3470.  
  3471.  
  3472. ___________________________________________________________________________
  3473.                                                                          52
  3474.  
  3475.  
  3476.  
  3477. Ultrasound Software Development Kit (SDK)                      Version 2.10
  3478. ___________________________________________________________________________
  3479.  
  3480. UltraWaveHandler
  3481. _________________________________
  3482.  
  3483. Purpose:   To define a callback for an end-of-wave interrupt.
  3484.  
  3485. C:         PFV *(UltraWaveHandler(handler));
  3486.            PFV *handler;
  3487.  
  3488. PASCAL:    PROCEDURE UltraWaveHandler(VAR Handler : INT_PROC);
  3489.  
  3490. Remarks:   This  procedure  defines  a  callback   for  whenever  a  voice
  3491.            generates a  wavetable interrupt.   This  happens when  a voice
  3492.            hits it's end and interrupts are  enabled.  It will happen even
  3493.            if looping is on (i.e.  the  voice keeps playing).  The routine
  3494.            address passed as a parameter is set as the new handler.
  3495.            Normally, This procedure  is used  to signify  that a  voice is
  3496.            done playing.  This handler can  be useful for starting another
  3497.            voice or counting the  # of times  that a voice  goes through a
  3498.            loop.  The voice # that  generated the interrupt is passed back
  3499.            to your handler.
  3500.  
  3501. Returns:   For C  users,  this  routine returns  the  address  of  the old
  3502.            handler.
  3503.  
  3504. PASCAL
  3505. Example:   See the example for UltraDRAMTcHandler.
  3506.  
  3507.  
  3508.  
  3509. UltraVolumeHandler
  3510. _________________________________
  3511.  
  3512. Purpose:   To define a callback for volume ramp complete interrupt.
  3513.  
  3514. C:         PFV *(UltraVolumeHandler(handler));
  3515.            PFV *handler;
  3516.  
  3517. PASCAL:    PROCEDURE UltraVolumeHandler(VAR Handler : INT_PROC);
  3518.  
  3519. Remarks:   This procedure defines  a callback  for whenever a  volume ramp
  3520.            ends.  The routine address passed as  a parameter is set as the
  3521.            new handler.   This routine  can be used  to generate  a volume
  3522.            envelope (attack, decay,  sustain, release).   This is  done by
  3523.            changing to  the appropriate  volume  ramps in  the  handler to
  3524.            handle the next part of the envelope.   The voice # causing the
  3525.            interrupt will be passed back to your handler.
  3526.  
  3527. Returns:   For C  users,  this  routine returns  the  address  of  the old
  3528.            handler.
  3529.  
  3530. PASCAL
  3531. Example:   See the example for UltraDRAMTcHandler.
  3532.  
  3533.  
  3534.  
  3535. ___________________________________________________________________________
  3536.                                                                          53
  3537.  
  3538.  
  3539.  
  3540. Ultrasound Software Development Kit (SDK)                      Version 2.10
  3541. ___________________________________________________________________________
  3542.  
  3543. UltraRecordHandler
  3544. _________________________________
  3545.  
  3546. Purpose:   To define a callback for a DMA record complete interrupt.
  3547.  
  3548. C:         PFV *(UltraUltraRecordHandler(handler));
  3549.            PFV *handler;
  3550.  
  3551. PASCAL:    PROCEDURE UltraRecordHandler(VAR Handler : PFV);
  3552.  
  3553. Remarks:   This routine is  called when a  buffer that  was being recorded
  3554.            into is full.  The routine address passed as a parameter is set
  3555.            as the new handler.  Normally,  this procedure would be used to
  3556.            let  the  application  start  up  another  record.    A  double
  3557.            buffering scheme could be used to record data continuously.  No
  3558.            parameters are passed to this handler.
  3559.            As long  as the  DMA channels  for  recording and  playback are
  3560.            different,  the   UltraSound  is   capable   of  simultaneously
  3561.            recording and playback.   At  high data rates  your application
  3562.            may have a problem with throughput.
  3563.  
  3564. Returns:   For C  users,  this  routine returns  the  address  of  the old
  3565.            handler.
  3566.  
  3567. PASCAL
  3568. Example:   See the example for UltraDRAMTcHandler.
  3569.  
  3570.  
  3571.  
  3572. UltraAuxHandler
  3573. _________________________________
  3574.  
  3575. Purpose:   To define a callback for an auxiliary interrupt.
  3576.  
  3577. C:         PFV *(UltraUltraAuxHandler(handler));
  3578.            PFV *handler;
  3579.  
  3580. PASCAL:    PROCEDURE UltraAuxHandler(VAR Handler : PFV);
  3581.  
  3582. Remarks:   This handler will be  called at the end  of ALL interrupts that
  3583.            happen on the UltraSound.  Its  primary purpose is for use with
  3584.            the new UltraMax card since its shares its IRQ with the GF1.
  3585.  
  3586. Returns:   For C  users,  this  routine returns  the  address  of  the old
  3587.            handler.
  3588.  
  3589. PASCAL
  3590. Example:   See the example for UltraDRAMTcHandler.
  3591.  
  3592.  
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598. ___________________________________________________________________________
  3599.                                                                          54
  3600.  
  3601.  
  3602.  
  3603. Ultrasound Software Development Kit (SDK)                      Version 2.10
  3604. ___________________________________________________________________________
  3605.  
  3606. UltraMaxAlloc
  3607. _________________________________
  3608.  
  3609. Purpose:   To find the size of the largest allocatable block of UltraSound
  3610.            DRAM.
  3611.  
  3612. C:         unsigned long UltraMaxAlloc(void);
  3613.  
  3614. PASCAL:    FUNCTION UltraMaxAlloc : LONGINT;
  3615.  
  3616. Remarks:   This routine will return  the largest block of  DRAM (in bytes)
  3617.            that  can  still  be  allocated.     This  can  be  useful  for
  3618.            determining whether or  not a  patch or  sample can  be loaded.
  3619.            The maximum size of a block is 256K.
  3620.  
  3621. Returns:   # of bytes in largest available block.
  3622.  
  3623. See also:  UltraMemAlloc, UltraMemFree,
  3624.            for C users UltraMemInit
  3625.            and for PASCAL users UltraMemAvail and UltraMaxAvail
  3626.  
  3627.  
  3628.  
  3629.  
  3630. UltraMaxAvail
  3631. _________________________________
  3632.  
  3633. Purpose:   To find the size of the largest allocatable block of UltraSound
  3634.            DRAM.
  3635.  
  3636. C:         Use the UltraMaxAlloc function.
  3637.  
  3638. PASCAL:    FUNCTION UltraMaxAvail : LONGINT;
  3639.  
  3640. Remarks:   This routine will return  the largest block of  DRAM (in bytes)
  3641.            that  can  still  be  allocated.     This  can  be  useful  for
  3642.            determining whether or  not a  patch or  sample can  be loaded.
  3643.            The maximum size of a block is  256K.  This routine is included
  3644.            to provide consistency of naming for PASCAL Programmers.
  3645.  
  3646. Returns:   # of bytes in largest available block.
  3647.  
  3648. See also:  UltraMemAlloc, UltraMemFree,
  3649.            for C users UltraMemInit
  3650.            and for PASCAL users UltraMemAvail
  3651.  
  3652.  
  3653.  
  3654.  
  3655.  
  3656.  
  3657.  
  3658.  
  3659.  
  3660.  
  3661. ___________________________________________________________________________
  3662.                                                                          55
  3663.  
  3664.  
  3665.  
  3666. Ultrasound Software Development Kit (SDK)                      Version 2.10
  3667. ___________________________________________________________________________
  3668.  
  3669. UltraMemAvail
  3670. _________________________________
  3671.  
  3672. Purpose:   To find the total amount of free UltraSound DRAM.
  3673.  
  3674. C:         This function is not available.
  3675.  
  3676. PASCAL:    FUNCTION UltraMemAvail : LONGINT;
  3677.  
  3678. Remarks:   For PASCAL users,  this will  return the  total amount  of DRAM
  3679.            still available for use on the UltraSound.
  3680.  
  3681. Returns:   # of bytes in left available.
  3682.  
  3683. See also:  UltraMemAlloc, UltraMemFree, UltraMaxAlloc
  3684.            for C users UltraMemInit
  3685.            and for PASCAL users UltraMaxAvail
  3686.  
  3687.  
  3688.  
  3689. UltraMemAlloc
  3690. _________________________________
  3691.  
  3692. Purpose:   To safely allocate a chunk of UltraSound DRAM.
  3693.  
  3694. C:         int UltraMemAlloc(size, location);
  3695.            unsigned long size;
  3696.            unsigned long *location;
  3697.  
  3698. PASCAL:    FUNCTION UltraMemAlloc(    Size     : LONGINT;
  3699.                                   VAR Location : LONGINT) : BOOLEAN;
  3700.  
  3701. Remarks:   This routine allocates a chunk of DRAM of 'Size' bytes from the
  3702.            UltraSound's DRAM.  The memory allocation structures are set up
  3703.            by UltraOpen.  'Location'  is filled in with  the DRAM location
  3704.            of the  start  of the  chunk  of memory.    The  memory address
  3705.            returned will ALWAYS be  aligned on a 32  byte boundary so that
  3706.            the DRAM can be DMA'ed into without error.  Also, the size will
  3707.            be rounded UP to the  next 32 byte boundary.   PASCAL users can
  3708.            reference section 1.8.3 for  a detailed look at  how the memory
  3709.            is managed.
  3710.  
  3711. Returns:   C:      ULTRA_OK if no problem.
  3712.                    NO_MEMORY if there is no chunk of DRAM large enough.
  3713.  
  3714.            PASCAL: TRUE if the allocation was successful.
  3715.                    If FALSE, check UltraErrorStr for the reason.
  3716.  
  3717. See also:  UltraMemFree, UltraMaxAlloc,
  3718.            for C users UltraMemInit
  3719.            and for PASCAL users UltraMaxAvail and UltraMemAvail
  3720.  
  3721.  
  3722.  
  3723.  
  3724. ___________________________________________________________________________
  3725.                                                                          56
  3726.  
  3727.  
  3728.  
  3729. Ultrasound Software Development Kit (SDK)                      Version 2.10
  3730. ___________________________________________________________________________
  3731.  
  3732. UltraMemFree
  3733. _________________________________
  3734.  
  3735. Purpose:   To  free   a   chunk   of   DRAM   previously  allocated   with
  3736.            UltraMemAlloc.
  3737.  
  3738. C:         int UltraMemFree(size,location);
  3739.            unsigned long size;
  3740.            unsigned long location;
  3741.  
  3742. PASCAL:    FUNCTION  UltraMemFree(Size     : LONGINT;
  3743.                                   Location : LONGINT) : BOOLEAN;
  3744.  
  3745. Remarks:   Frees a previously allocated  chunk of UltraSound  memory.  The
  3746.            size will  automatically  be rounded  UP  to the  next  32 byte
  3747.            boundary.
  3748.  
  3749. Returns:   C:      ULTRA_OK if no problem.
  3750.                    CORRUPT_MEM if the memory structures are corrupted.
  3751.  
  3752.            PASCAL: TRUE if deallocation was successful.
  3753.                    If FALSE, check UltraErrorStr for the reason.
  3754.  
  3755. See also:  UltraMemInit, UltraMemAlloc
  3756.            for C users UltraMemInit
  3757.            and for PASCAL users UltraMaxAvail and UltraMemAvail
  3758.  
  3759.  
  3760.  
  3761. UltraMemInit
  3762. _________________________________
  3763.  
  3764. Purpose:   To initialize or re-initialize the memory pool structures.
  3765.  
  3766. C:         unsigned long UltraMemInit(void);
  3767.  
  3768. PASCAL:    This routine is not  used.  The unit  automatically calls these
  3769.            routines when your program starts.
  3770.  
  3771. Remarks:   This routine sets up the UltraSound  DRAM so that UltraMemAlloc
  3772.            and UltraMemFree will work.  It is called in UltraOpen.  It can
  3773.            be called at any time  if an application wants  to clean up all
  3774.            its allocated or corrupted memory structures.
  3775.  
  3776. Returns:   Number of K of DRAM found on the UltraSound.  If an application
  3777.            wishes to reserve a chunk of DRAM outside of the memory pool, a
  3778.            variable called _ultra_reserved_dram must be set  up with the #
  3779.            of bytes  to  reserve  BEFORE  UltraMemInit  is  called.   This
  3780.            reserved chunk will  start at  0.  The  reserved chunk  must be
  3781.            greater than 32 bytes and less than 256K in size.
  3782.  
  3783. See also:  UltraMemAlloc, UltraMemFree, and UltraMaxAlloc
  3784.  
  3785.  
  3786.  
  3787. ___________________________________________________________________________
  3788.                                                                          57
  3789.  
  3790.  
  3791.  
  3792. Ultrasound Software Development Kit (SDK)                      Version 2.10
  3793. ___________________________________________________________________________
  3794.  
  3795. UltraMIDIDisableRecv
  3796. _________________________________
  3797.  
  3798. Purpose:   To disable the MIDI receive data interrupt.
  3799.  
  3800. C:         void UltraMIDIDisableRecv(void);
  3801.  
  3802. PASCAL:    PROCEDURE UltraMIDIDisableRecv;
  3803.  
  3804. Remarks:   This routine will disable the receive  data interrupts from the
  3805.            MIDI.   If  the interrupt  is  enabled, it  should  be disabled
  3806.            before leaving your application.
  3807.  
  3808. See also:  UltraMIDIEnableRecv, UltraMIDIRecvHandler
  3809.  
  3810.  
  3811.  
  3812. UltraDisableMIDIXmit
  3813. _________________________________
  3814.  
  3815. Purpose:   To disable MIDI transmit interrupts.
  3816.  
  3817. C:         void UltraDisableMIDIXmit(void);
  3818.  
  3819. PASCAL:    PROCEDURE UltraDisableMIDIXmit;
  3820.  
  3821. Remarks:   This routine will turn  off MIDI transmit interrupts.   It MUST
  3822.            be called when you are through sending data.
  3823.  
  3824. See also:  UltraMIDIXmitHandler, UltraMIDIEnableXmit
  3825.  
  3826.  
  3827.  
  3828. UltraMIDIEnableRecv
  3829. _________________________________
  3830.  
  3831. Purpose:   To enable receive data interrupts for MIDI port.
  3832.  
  3833. C:         void UltraMIDIEnableRecv(void);
  3834.  
  3835. PASCAL:    PROCEDURE UltraMIDIEnableRecv;
  3836.  
  3837. Remarks:   This routine will enable receive data  interrupts from the MIDI
  3838.            port.  It is  necessary to set  up a callback  routine for your
  3839.            application to process the data.
  3840.  
  3841. See also:  UltraMIDIRecvhandler, UltraMIDIDisableRecv
  3842.  
  3843.  
  3844.  
  3845.  
  3846.  
  3847.  
  3848.  
  3849.  
  3850. ___________________________________________________________________________
  3851.                                                                          58
  3852.  
  3853.  
  3854.  
  3855. Ultrasound Software Development Kit (SDK)                      Version 2.10
  3856. ___________________________________________________________________________
  3857.  
  3858. UltraEnableMIDIXmit
  3859. _________________________________
  3860.  
  3861. Purpose:   To enable transmit interrupts from MIDI.
  3862.  
  3863. C:         void UltraEnableMIDIXmit(void);
  3864.  
  3865. PASCAL:    PROCEDURE UltraEnableMIDIXmit;
  3866.  
  3867. Remarks:   This  routine  will  enable  transmit  data  interrupts  to  be
  3868.            generated as each byte is transmitted  out the MIDI port.  Note
  3869.            that a transmit interrupt will be  generated as soon as the IRQ
  3870.            is enabled  unless  a byte  is  sent out  immediately  prior to
  3871.            enabling it.   This  is because  the  xmit buffer  is initially
  3872.            empty (unless primed) so  it will pop an  interrupt.  Also note
  3873.            that you MUST disable  this interrupt when you  are not sending
  3874.            any more  data or  else you  will be  hung up  getting transmit
  3875.            ready interrupts.
  3876.  
  3877. See also:  UltraMIDIXmitHandler, UltraMIDIDisableXmit
  3878.  
  3879.  
  3880.  
  3881. UltraMIDIRecv
  3882. _________________________________
  3883.  
  3884. Purpose:   To read a byte from the MIDI port.
  3885.  
  3886. C:         unsigned char UltraMIDIRecv(void);
  3887.  
  3888. PASCAL:    FUNCTION UltraMIDIRecv : BYTE;
  3889.  
  3890. Remarks:   This routine is  used to read  a byte from  the MIDI  port.  It
  3891.            assumes that the byte is waiting.  The  Byte is there if it got
  3892.            to the MIDI receive  interrupt callback routine or  if you have
  3893.            polled the status and determined the receive buffer is full.
  3894.  
  3895. Returns:   MIDI data byte
  3896.  
  3897. See also:  UltraMIDIRecvHandler, UltraMIDIStatus
  3898.  
  3899.  
  3900.  
  3901.  
  3902.  
  3903.  
  3904.  
  3905.  
  3906.  
  3907.  
  3908.  
  3909.  
  3910.  
  3911.  
  3912.  
  3913. ___________________________________________________________________________
  3914.                                                                          59
  3915.  
  3916.  
  3917.  
  3918. Ultrasound Software Development Kit (SDK)                      Version 2.10
  3919. ___________________________________________________________________________
  3920.  
  3921. UltraMIDIReset
  3922. _________________________________
  3923.  
  3924. Purpose:   To reset the MIDI port.
  3925.  
  3926. C:         void UltraMIDIReset(void);
  3927.  
  3928. PASCAL:    PROCEDURE UltraMIDIReset;
  3929.  
  3930. Remarks:   This routine should  be used  to ensure that  the MIDI  port is
  3931.            ready to use.   All  MIDI interrupts will  be disabled  by this
  3932.            call.
  3933.  
  3934. See also:  UltraEnableMIDIXmit, UltraEnableMIDIRecv
  3935.  
  3936.  
  3937.  
  3938. UltraMIDIStatus
  3939. _________________________________
  3940.  
  3941. Purpose:   To read the MIDI status byte.
  3942.  
  3943. C:         unsigned char UltraMIDIStatus(void);
  3944.  
  3945. PASCAL:    FUNCTION UltraMIDIStatus : BYTE;
  3946.  
  3947. Remarks:   This routine returns the  current MIDI port status  bits.  This
  3948.            can be used  to determine if  an error  has occurred  or if the
  3949.            port is ready to be read or written.
  3950.  
  3951. Returns:   The MIDI status byte.  See chapter 2.
  3952.  
  3953. See also:  UltraMIDIXmit, UltraMIDIRecv
  3954.  
  3955.  
  3956.  
  3957.  
  3958. UltraMIDIXmit
  3959. _________________________________
  3960.  
  3961. Purpose:   To send a byte out the MIDI port.
  3962.  
  3963. C:         void UltraMIDIXmit(data);
  3964.            unsigned char data;
  3965.  
  3966. PASCAL:    PROCEDURE UltraMIDIXmit(Data : BYTE);
  3967.  
  3968. Remarks:   This routine will send the 'Data'  byte out the MIDI data port.
  3969.            If interrupts are enabled, an interrupt  will be generated when
  3970.            the Byte has been transmitted.
  3971.  
  3972. See also:  UltraMIDIXmitHandler
  3973.  
  3974.  
  3975.  
  3976. ___________________________________________________________________________
  3977.                                                                          60
  3978.  
  3979.  
  3980.  
  3981. Ultrasound Software Development Kit (SDK)                      Version 2.10
  3982. ___________________________________________________________________________
  3983.  
  3984. UltraOpen
  3985. _________________________________
  3986.  
  3987. Purpose:   To open and initialize the UltraSound card and the SDK code.
  3988.  
  3989. C:         int UltraOpen(config,voices);
  3990.            ULTRA_CFG *config;
  3991.            int voices;
  3992.  
  3993. PASCAL:    FUNCTION  UltraOpen(VAR Config : Ultra_CFG;
  3994.                                    Voices : INTEGER) : BOOLEAN;
  3995.  
  3996. Remarks:   This  routine  should  ALWAYS  be   called  to  initialize  the
  3997.            UltraSound.  It will probe for the card and program the IRQ and
  3998.            DMA latches.   It will then  disable line  and microphone input
  3999.            and enable output.  It also  initializes the memory structures.
  4000.            The #  of  active  voices  is  an  important  parameter to  the
  4001.            UltraSound: the fewer  the #  of voices, the  more oversampling
  4002.            that occurs  on  playback.    This  will  make  the sound  much
  4003.            'cleaner'.  If you specify a number of voices less than 14, the
  4004.            card will still be initialized to  use 14 voices.  Likewise, if
  4005.            you select larger than 32 voices, you will still only have 32.
  4006.  
  4007. Returns:   C:      ULTRA_OK if no problem.
  4008.                    NO_ULTRA if no UltraSound card found.
  4009.                    BAD_NUM_OF_VOICES if # of active voices out of range
  4010.  
  4011.            PASCAL: TRUE if the card was successfully opened.
  4012.                    If FALSE, check UltraErrorStr for the reason.
  4013.  
  4014. See also:  UltraClose, UltraProbe
  4015.  
  4016.  
  4017.  
  4018.  
  4019.  
  4020.  
  4021.  
  4022.  
  4023.  
  4024.  
  4025.  
  4026.  
  4027.  
  4028.  
  4029.  
  4030.  
  4031.  
  4032.  
  4033.  
  4034.  
  4035.  
  4036.  
  4037.  
  4038.  
  4039. ___________________________________________________________________________
  4040.                                                                          61
  4041.  
  4042.  
  4043.  
  4044. Ultrasound Software Development Kit (SDK)                      Version 2.10
  4045. ___________________________________________________________________________
  4046.  
  4047. UltraPeekData
  4048. _________________________________
  4049.  
  4050. Purpose:   To examine any DRAM location on the UltraSound.
  4051.  
  4052. C:         unsigned char UltraPeekData(baseport,location);
  4053.            unsigned int baseport;
  4054.            unsigned long location;
  4055.  
  4056. PASCAL:    FUNCTION UltraPeekData(PPort   : INTEGER;
  4057.                                   Address : LONGINT) : BYTE;
  4058.  
  4059. Remarks:   This routine is  used to  allow an application  to look  at any
  4060.            location in UltraSound's DRAM.  This can be handy for obtaining
  4061.            VU information or any other time it is  nice to know what is in
  4062.            DRAM.  Be aware that if the data is playable it will be in twos
  4063.            compliment form.  If the data that you want is 16 bit data, you
  4064.            will need  to  peek  both  locations  and  do  any  appropriate
  4065.            conversions.  The data will be  in low/high format.  That means
  4066.            that the low byte of the data will be  in the even byte and the
  4067.            high byte will be in the odd byte.
  4068.  
  4069. Returns:   Data byte at location specified.
  4070.  
  4071. See also:  UltraPokeData, UltraUpload
  4072.  
  4073.  
  4074.  
  4075. UltraPing
  4076. _________________________________
  4077.  
  4078. Purpose:   To quickly  check  to see  if  an UltraSound  is  present  at a
  4079.            specified port.
  4080.  
  4081. C:         int UltraPing(baseport);
  4082.            int baseport;
  4083.  
  4084. PASCAL:    FUNCTION UltraPing(PPort : WORD) : BOOLEAN;
  4085.  
  4086. Remarks:   This routine  will determine  if  an UltraSound  is  present by
  4087.            attempting to read and write to its DRAM.  This routine assumes
  4088.            that at least  a simple reset  has been done  since power-up so
  4089.            that the board is  no longer in a  reset state.  If  it is on a
  4090.            reset state, this routine will ALWAYS fail.  UltraProbe pulls a
  4091.            quick reset and then calls UltraPing.
  4092.  
  4093. Returns:   C:      ULTRA_OK if no problem.
  4094.                    NO_ULTRA if no board is found at specified I/O port.
  4095.  
  4096.            PASCAL: TRUE if the card was found.   FALSE otherwise.
  4097.                    If unsuccessful, check UltraErrorStr for the reason.
  4098.  
  4099. See also:  UltraProbe
  4100.  
  4101.  
  4102. ___________________________________________________________________________
  4103.                                                                          62
  4104.  
  4105.  
  4106.  
  4107. Ultrasound Software Development Kit (SDK)                      Version 2.10
  4108. ___________________________________________________________________________
  4109.  
  4110. UltraPokeData
  4111. _________________________________
  4112.  
  4113. Purpose:   To poke a byte into the UltraSound's DRAM.
  4114.  
  4115. C:         void UltraPokeData(baseport,location,data);
  4116.            unsigned int baseport;
  4117.            unsigned long location;
  4118.            unsigned char data;
  4119.  
  4120. PASCAL:    PROCEDURE UltraPokeData(PPort   : INTEGER;
  4121.                                    Address : LONGINT;
  4122.                                    Data    : BYTE);
  4123.  
  4124. Remarks:   Poke an 8 bit value directly into UltraSound DRAM.  This can be
  4125.            useful to  set  the  value of  the  location  that  a  voice is
  4126.            pointing to.  It is often desirable to point a voice to a known
  4127.            value since its output  is ALWAYS summed in  to the output even
  4128.            if the  voice  is not  running.    Be aware  that  there  is no
  4129.            automatic conversion  of  data  poked  into  DRAM.   Since  the
  4130.            UltraSound can only play  twos compliment data,  make sure that
  4131.            the data you  are poking is  in that  format.   Also be careful
  4132.            with 16 bit data.
  4133.  
  4134. See also:  UltraPeekData, UltraDownload
  4135.  
  4136.  
  4137.  
  4138.  
  4139.  
  4140.  
  4141.  
  4142.  
  4143.  
  4144.  
  4145.  
  4146.  
  4147.  
  4148.  
  4149.  
  4150.  
  4151.  
  4152.  
  4153.  
  4154.  
  4155.  
  4156.  
  4157.  
  4158.  
  4159.  
  4160.  
  4161.  
  4162.  
  4163.  
  4164.  
  4165. ___________________________________________________________________________
  4166.                                                                          63
  4167.  
  4168.  
  4169.  
  4170. Ultrasound Software Development Kit (SDK)                      Version 2.10
  4171. ___________________________________________________________________________
  4172.  
  4173. UltraPrimeRecord
  4174. _________________________________
  4175.  
  4176. Purpose:   To prime the record DMA channel for use.
  4177.  
  4178. C:         int UltraPrimeRecord(pc_ptr,size,repeat);
  4179.            void far *pc_ptr;
  4180.            unsigned int size;
  4181.            int repeat;
  4182.  
  4183. PASCAL:    FUNCTION UltraPrimeRecord(PC_Ptr  : POINTER;
  4184.                                      Size    : WORD;
  4185.                                      RRepeat : BOOLEAN) : BOOLEAN;
  4186.  
  4187. Remarks:   This routine will  setup the  DMA channel to  do a  record, but
  4188.            does not  start  it.   This  can be  used  to  help synchronize
  4189.            events.  Programming  the DMA channel  can take  enough time so
  4190.            that a few  samples may be  lost.  (Depending  on sample rate).
  4191.            This routine  will help  alleviate  this problem  by  doing the
  4192.            programming ahead of time.
  4193.  
  4194. Returns:   C:      ULTRA_OK if no problem.
  4195.                    DMA_BUSY if DMA Channel is busy.
  4196.  
  4197.            PASCAL: TRUE if setup was successful.   FALSE otherwise.
  4198.                    If unsuccessful, check UltraErrorStr for the reason.
  4199.  
  4200. See also:  UltraGoRecord
  4201.  
  4202.  
  4203.  
  4204.  
  4205.  
  4206.  
  4207.  
  4208.  
  4209.  
  4210.  
  4211.  
  4212.  
  4213.  
  4214.  
  4215.  
  4216.  
  4217.  
  4218.  
  4219.  
  4220.  
  4221.  
  4222.  
  4223.  
  4224.  
  4225.  
  4226.  
  4227.  
  4228. ___________________________________________________________________________
  4229.                                                                          64
  4230.  
  4231.  
  4232.  
  4233. Ultrasound Software Development Kit (SDK)                      Version 2.10
  4234. ___________________________________________________________________________
  4235.  
  4236. UltraPrimeVoice
  4237. _________________________________
  4238.  
  4239. Purpose:   To prime a voice with values but NOT start it.
  4240.  
  4241. C:         unsigned char UltraPrimeVoice(voice,begin,start,end,mode);
  4242.            int voice;
  4243.            unsigned long begin;
  4244.            unsigned long start;
  4245.            unsigned long end;
  4246.            unsigned char mode;
  4247.  
  4248. PASCAL:    FUNCTION UltraPrimeVoice(Voice    : INTEGER;
  4249.                                     VBegin   : LONGINT;
  4250.                                     VStart   : LONGINT;
  4251.                                     VEnd     : LONGINT;
  4252.                                     VMode    : BYTE) : BYTE;
  4253.  
  4254. Remarks:   This routine is used to  do all the setup  necessary to start a
  4255.            voice but does NOT start it up.  This can be useful if you want
  4256.            to  start  more   than  1  voice   at  the  same   time.    Use
  4257.            UltraPrimeVoice to  do all  the  necessary setup  and  then use
  4258.            UltraGoVoice  to  start  the  voices.    UltraStartVoice  calls
  4259.            UltraPrimeVoice and then immediately UltraGoVoice.
  4260.  
  4261. Returns:   An updated mode value.   The mode may be  modified on the basis
  4262.            of the location parameters.   This altered value  should be the
  4263.            one passed to UltraGoVoice.
  4264.  
  4265. See also:  UltraStartVoice, UltraGoVoice
  4266.  
  4267.  
  4268.  
  4269.  
  4270.  
  4271.  
  4272.  
  4273.  
  4274.  
  4275.  
  4276.  
  4277.  
  4278.  
  4279.  
  4280.  
  4281.  
  4282.  
  4283.  
  4284.  
  4285.  
  4286.  
  4287.  
  4288.  
  4289.  
  4290.  
  4291. ___________________________________________________________________________
  4292.                                                                          65
  4293.  
  4294.  
  4295.  
  4296. Ultrasound Software Development Kit (SDK)                      Version 2.10
  4297. ___________________________________________________________________________
  4298.  
  4299. UltraProbe
  4300. _________________________________
  4301.  
  4302. Purpose:   To probe  for the  existence of  an  UltraSound at  a specified
  4303.            port.
  4304.  
  4305. C:         int UltraProbe(base_port);
  4306.            unsigned int base_port;
  4307.  
  4308. PASCAL:    FUNCTION UltraProbe(PPort : WORD) : BOOLEAN;
  4309.  
  4310. Remarks:   This routine probes for the existence  of an UltraSound card at
  4311.            the specified base port.  An application could call this before
  4312.            calling UltraOpen to see if a card is present.  UltraOpen calls
  4313.            this routine  also.    The  difference  between UltraProbe  and
  4314.            UltraPing is that UltraProbe will pull a reset to make sure the
  4315.            board is  running.   UltraPing  assumes this  has  already been
  4316.            done.
  4317.  
  4318. Returns:   C:      ULTRA_OK if no problem.
  4319.                    NO_ULTRA if no card was found at the port specified.
  4320.  
  4321.            PASCAL: TRUE if the card is found.   FALSE otherwise.
  4322.                    If unsuccessful, check UltraErrorStr for the reason.
  4323.  
  4324. See also:  UltraOpen, UltraPing
  4325.  
  4326.  
  4327.  
  4328.  
  4329.  
  4330.  
  4331.  
  4332.  
  4333.  
  4334.  
  4335.  
  4336.  
  4337.  
  4338.  
  4339.  
  4340.  
  4341.  
  4342.  
  4343.  
  4344.  
  4345.  
  4346.  
  4347.  
  4348.  
  4349.  
  4350.  
  4351.  
  4352.  
  4353.  
  4354. ___________________________________________________________________________
  4355.                                                                          66
  4356.  
  4357.  
  4358.  
  4359. Ultrasound Software Development Kit (SDK)                      Version 2.10
  4360. ___________________________________________________________________________
  4361.  
  4362. UltraRampVolume
  4363. _________________________________
  4364.  
  4365. Purpose:   To ramp a voice's volume up or down.
  4366.  
  4367. C:         void UltraRampVolume(voice,start,end,rate,mode);
  4368.            int voice;
  4369.            unsigned int start;
  4370.            unsigned int end;
  4371.            unsigned char rate;
  4372.            unsigned char mode;
  4373.  
  4374. PASCAL:    PROCEDURE UltraRampVolume(Voice  : INTEGER;
  4375.                                      StartV : WORD;
  4376.                                      EndV   : WORD;
  4377.                                      VRate  : BYTE;
  4378.                                      VMode  : BYTE);
  4379.  
  4380. Remarks:   Start a  volume  ramp  from a  starting  volume  to  the ending
  4381.            volume.  The  rate at which  the ramp occurs  can be calculated
  4382.            using UltraCalcRate.    The  mode  determines  the looping  and
  4383.            interrupting characteristics  of the  ramp.   If you  choose to
  4384.            have it interrupt at the end of the  ramp, you should set up an
  4385.            routine to call for a volume interrupt.   This is done with the
  4386.            routine UltraVolumeHandler.   The volume mode  bits are defined
  4387.            in Appendix B.
  4388.  
  4389. See also:  UltraCalcRate, UltraVolumeHandler
  4390.  
  4391.  
  4392.  
  4393. UltraReadRecordPosition
  4394. _________________________________
  4395.  
  4396. Purpose:   To return the # of bytes recorded so far in a record.
  4397.  
  4398. C:         unsigned int UltraReadRecordPosition(void);
  4399.  
  4400. PASCAL:    FUNCTION UltraReadRecordPosition : WORD;
  4401.  
  4402. Remarks:   This routine can be used to monitor the amount data recorded.
  4403.  
  4404. Returns:   Number of BYTES recorded so far.
  4405.  
  4406. See also:  UltraRecordData
  4407.  
  4408.  
  4409.  
  4410.  
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417. ___________________________________________________________________________
  4418.                                                                          67
  4419.  
  4420.  
  4421.  
  4422. Ultrasound Software Development Kit (SDK)                      Version 2.10
  4423. ___________________________________________________________________________
  4424.  
  4425. UltraReadVoice
  4426. _________________________________
  4427.  
  4428. Purpose:   To read a voice's current location.
  4429.  
  4430. C:         unsigned long UltraReadVoice(voice);
  4431.            int voice;
  4432.  
  4433. PASCAL:    FUNCTION UltraReadVoice(Voice : INTEGER) : LONGINT;
  4434.  
  4435. Remarks:   This routine can be used to monitor a voice's progress.
  4436.  
  4437. Returns:   The voice's current position in DRAM.
  4438.  
  4439. See also:  UltraSetVoice
  4440.  
  4441.  
  4442.  
  4443. UltraReadVolume
  4444. _________________________________
  4445.  
  4446. Purpose:   To read a voice's current volume.
  4447.  
  4448. C:         unsigned int UltraReadVolume(voice);
  4449.            int voice;
  4450.  
  4451. PASCAL:    FUNCTION UltraReadVolume(Voice : INTEGER) : WORD;
  4452.  
  4453. Remarks:   This routine returns the  current volume of a  voice.  This can
  4454.            be useful  when used  in conjunction  with  volume ramps.   The
  4455.            value returned is  logarithmic, not  linear.  PASCAL  users can
  4456.            use UltraReadLinearVolume.
  4457.  
  4458. Returns:   0-4095 value, the current logarithmic volume.
  4459.  
  4460. See also:  UltraSetVolume, UltraRampVolume
  4461.  
  4462.  
  4463.  
  4464.  
  4465.  
  4466.  
  4467.  
  4468.  
  4469.  
  4470.  
  4471.  
  4472.  
  4473.  
  4474.  
  4475.  
  4476.  
  4477.  
  4478.  
  4479.  
  4480. ___________________________________________________________________________
  4481.                                                                          68
  4482.  
  4483.  
  4484.  
  4485. Ultrasound Software Development Kit (SDK)                      Version 2.10
  4486. ___________________________________________________________________________
  4487.  
  4488. UltraRecordData
  4489. _________________________________
  4490.  
  4491. Purpose:   To record some  data with the  UltraSound from  the active 'In'
  4492.            ports.
  4493.  
  4494. C:         int UltraRecordData(pc_ptr,control,size,wait,repeat);
  4495.            void far *pc_ptr;
  4496.            unsigned char control;
  4497.            unsigned int size;
  4498.            int wait;
  4499.            int repeat;
  4500.  
  4501. PASCAL:    FUNCTION UltraRecordData(PC_Ptr  : POINTER;
  4502.                                     Control : BYTE;
  4503.                                     Size    : WORD;
  4504.                                     Wait    : BOOLEAN;
  4505.                                     RRepeat : BOOLEAN) : BOOLEAN;
  4506.  
  4507. Remarks:   This routine will record a buffer  of data from UltraSound.  It
  4508.            can be in either  8-bit mono or  stereo.  In  stereo, there are
  4509.            two bytes and the left byte  is first.  If  mono is being used,
  4510.            the left channel is  the one that  is sampled.   See Appendix E
  4511.            for the a description of the recording control bits.  If 'wait'
  4512.            is set to a  non-zero value, then this  routine will not return
  4513.            until the buffer  has been filled.   If 'repeat'  is TRUE, then
  4514.            the DMA channel will  be set up  in auto-init mode  so that the
  4515.            recording is  done indefinitely.   If  this  is done,  then the
  4516.            buffer MUST reside completely in  1 64K page of  PC RAM.  Also,
  4517.            it is  probably necessary  that your  application hooks  to the
  4518.            record handler so that  the control register  on the UltraSound
  4519.            can be hit  to restart  the recording  process (UltraGoRecord).
  4520.            This will be very quick since the PC DMA controller will not be
  4521.            re-programmed.
  4522.  
  4523. Returns:   C:      ULTRA_OK if no problem.
  4524.                    DMA_BUSY if sampling DMA Channel is busy.
  4525.                    BAD_DMA_ADDR if autoinit buffer crosses 64k page.
  4526.  
  4527.            PASCAL: TRUE if successful.   FALSE otherwise.
  4528.                    If unsuccessful, check UltraErrorStr for the reason.
  4529.  
  4530. See also:  UltraWaitRecordDMA, UltraSetRecordFrequency
  4531.            UltraGoRecord
  4532.  
  4533.  
  4534.  
  4535.  
  4536.  
  4537.  
  4538.  
  4539.  
  4540.  
  4541.  
  4542.  
  4543. ___________________________________________________________________________
  4544.                                                                          69
  4545.  
  4546.  
  4547.  
  4548. Ultrasound Software Development Kit (SDK)                      Version 2.10
  4549. ___________________________________________________________________________
  4550.  
  4551. UltraRecordDMABusy
  4552. _________________________________
  4553.  
  4554. Purpose:   To see if the record DMA channel is busy.
  4555.  
  4556. C:         int UltraRecordDMABusy(void);
  4557.  
  4558. PASCAL:    FUNCTION UltraRecordDMABusy : BOOLEAN;
  4559.  
  4560. Remarks:   This routine checks to  see if the record  DMA channel is busy.
  4561.            It might be busy  doing a record  (or playback if  the record &
  4562.            playback channels are the same).
  4563.  
  4564. Returns:   C:      0 = Channel not Busy
  4565.                    2 = Channel Busy
  4566.  
  4567.            PASCAL: TRUE if the channel is not available. FALSE if it is.
  4568.  
  4569. See also:  UltraRecordData
  4570.  
  4571.  
  4572.  
  4573. UltraReset
  4574. _________________________________
  4575.  
  4576. Purpose:   To reset the UltraSound.
  4577.  
  4578. C:         int UltraReset(voices);
  4579.            int voices;
  4580.  
  4581. PASCAL:    FUNCTION UltraReset(Voices : INTEGER) : BOOLEAN;
  4582.  
  4583. Remarks:   This routine is called by UltraOpen to make sure the card is in
  4584.            a known state.  UltraClose also calls this routine.
  4585.  
  4586. Returns:   C:      ULTRA_OK if no problem.
  4587.                    BAD_NUM_OF_VOICES if # of voices not in range.
  4588.  
  4589.            PASCAL: TRUE if card is successfully reset.
  4590.                    If FALSE, check UltraErrorStr for the reason.
  4591.  
  4592. See also:  UltraOpen, UltraClose
  4593.  
  4594.  
  4595.  
  4596.  
  4597.  
  4598.  
  4599.  
  4600.  
  4601.  
  4602.  
  4603.  
  4604.  
  4605.  
  4606. ___________________________________________________________________________
  4607.                                                                          70
  4608.  
  4609.  
  4610.  
  4611. Ultrasound Software Development Kit (SDK)                      Version 2.10
  4612. ___________________________________________________________________________
  4613.  
  4614. UltraSetBalance
  4615. _________________________________
  4616.  
  4617. Purpose:   To set a voice's pan position.
  4618.  
  4619. C:         void UltraSetBalance(voice,data);
  4620.            int voice;
  4621.            int data;
  4622.  
  4623. PASCAL:    PROCEDURE UltraSetBalance(Voice : INTEGER;
  4624.                                      Data  : BYTE);
  4625.  
  4626. Remarks:   This routine sets the  voice's position between  right and left
  4627.            speakers.  A  0 will place  the audio all  the way  to the left
  4628.            whereas a  15 will  put the  sound all  the  way to  the right.
  4629.            Values that  are out  of range  will  move the  balance  to the
  4630.            nearest extreme.
  4631.  
  4632.  
  4633.  
  4634. UltraSetFrequency
  4635. _________________________________
  4636.  
  4637. Purpose:   To set a voice's playback frequency.
  4638.  
  4639. C:         void UltraSetFrequency(voice,speed_hz);
  4640.            int voice;
  4641.            unsigned long speed_hz;
  4642.  
  4643. PASCAL:    PROCEDURE UltraSetFrequency(Voice     : INTEGER;
  4644.                                        Speed_Khz : LONGINT);
  4645.  
  4646. Remarks:   This routine sets  the voice's  playback rate to  the specified
  4647.            absolute frequency.  The number of  active voices is taken into
  4648.            account when making the appropriate calculations.
  4649.  
  4650.  
  4651.  
  4652. UltraSetLoopMode
  4653. _________________________________
  4654.  
  4655. Purpose:   To set a voice's loop mode.
  4656.  
  4657. C:         void UltraSetLoopMode(voice,mode);
  4658.            int voice;
  4659.            unsigned char mode;
  4660.  
  4661. PASCAL:    PROCEDURE UltraSetLoopMode(Voice : INTEGER;
  4662.                                       VMode : BYTE);
  4663.  
  4664. Remarks:   This  routine  will  set  this  voice's  looping  mode  to  the
  4665.            specified mode.   See Appendix  C for  the definition  of these
  4666.            bits.
  4667.  
  4668.  
  4669. ___________________________________________________________________________
  4670.                                                                          71
  4671.  
  4672.  
  4673.  
  4674. Ultrasound Software Development Kit (SDK)                      Version 2.10
  4675. ___________________________________________________________________________
  4676.  
  4677. UltraSetRecordFrequency
  4678. _________________________________
  4679.  
  4680. Purpose:   To set the recording rate.
  4681.  
  4682. C:         void UltraSetRecordFrequency(rate);
  4683.            unsigned long rate;
  4684.  
  4685. PASCAL:    PROCEDURE UltraSetRecordFrequency(Rate : LONGINT);
  4686.  
  4687. Remarks:   This routine sets the  record rate to  the specified frequency.
  4688.            Since the UltraSound uses the PC DMA channel to do the sampling
  4689.            directly into PC RAM, no voice specification is necessary.
  4690.  
  4691.  
  4692.  
  4693. UltraSetVoice
  4694. _________________________________
  4695.  
  4696. Purpose:   To set a voice to an absolute position in DRAM.
  4697.  
  4698. C:         void UltraSetVoice(voice,location);
  4699.            int voice;
  4700.            unsigned long location;
  4701.  
  4702. PASCAL:    PROCEDURE UltraSetVoice(Voice    : INTEGER;
  4703.                                    Location : LONGINT);
  4704.  
  4705. Remarks:   This routine  sets a  voice's current  position to  an absolute
  4706.            location.  This can be useful to set a voice to a location with
  4707.            a known value since all voices' current locations are summed in
  4708.            to the output even if the voice is  not running.  'Pops' in the
  4709.            audio may result if a voice is  set to a location that contains
  4710.            a significant value.
  4711.  
  4712.  
  4713. UltraSetVoiceEnd
  4714. _________________________________
  4715.  
  4716. Purpose:   To set a voice's end position.
  4717.  
  4718. C:         void UltraSetVoiceEnd(voice,end);
  4719.            int voice;
  4720.            unsigned long end;
  4721.  
  4722. PASCAL:    PROCEDURE UltraSetVoiceEnd(Voice    : INTEGER;
  4723.                                       VEnd     : LONGINT);
  4724.  
  4725. Remarks:   This routine sets a new endpoint for the specified voice.  Used
  4726.            in conjunction  with UltraSetLoopMode  to turn  looping  off, a
  4727.            sampled decay can be implemented.
  4728.  
  4729. See also:  UltraSetLoopMode
  4730.  
  4731.  
  4732. ___________________________________________________________________________
  4733.                                                                          72
  4734.  
  4735.  
  4736.  
  4737. Ultrasound Software Development Kit (SDK)                      Version 2.10
  4738. ___________________________________________________________________________
  4739.  
  4740. UltraSetVolume
  4741. _________________________________
  4742.  
  4743. Purpose:   To set a voice's current logarithmic volume.
  4744.  
  4745. C:         void UltraSetVolume(voice,volume);
  4746.            int voice;
  4747.            unsigned int volume;
  4748.  
  4749. PASCAL:    PROCEDURE UltraSetVolume(Voice  : INTEGER;
  4750.                                     Volume : WORD);
  4751.  
  4752. Remarks:   This routine  sets  the  volume  of  the  voice  to a  specific
  4753.            logarithmic value.    The  range  is  from  0  to  4095.    Use
  4754.            UltraSetLinearVolume to do linear volumes.
  4755.  
  4756. See also:  UltraSetLinearVolume
  4757.  
  4758.  
  4759.  
  4760. UltraSizeDRAM
  4761. _________________________________
  4762.  
  4763. Purpose:   To Find the amount of DRAM available on the UltraSound.
  4764.  
  4765. C:         int UltraSizeDram(void);
  4766.  
  4767. PASCAL:    FUNCTION UltraSizeDRAM : INTEGER;
  4768.            Note:  This routine will always return the same value, which is
  4769.            the amount of DRAM  that has been  installed on the  card.  Use
  4770.            UltraMemAvail to see how much DRAM is still free.
  4771.  
  4772. Remarks:   For C users,  this routine could  be used by  an application to
  4773.            determine  how   much  it   can  load   into   the  UltraSound.
  4774.            UltraMemInit calls this to  determine how much can  be used for
  4775.            its memory pool.
  4776.  
  4777. Returns:   # of kilobytes found on the UltraSound.
  4778.  
  4779. See also:  UltraMemInit
  4780.  
  4781.  
  4782.  
  4783.  
  4784.  
  4785.  
  4786.  
  4787.  
  4788.  
  4789.  
  4790.  
  4791.  
  4792.  
  4793.  
  4794.  
  4795. ___________________________________________________________________________
  4796.                                                                          73
  4797.  
  4798.  
  4799.  
  4800. Ultrasound Software Development Kit (SDK)                      Version 2.10
  4801. ___________________________________________________________________________
  4802.  
  4803. UltraStartTimer
  4804. _________________________________
  4805.  
  4806. Purpose:   To set up and start either Timer 1 or Timer 2.
  4807.  
  4808. C:         void UltraStartTimer(timer,duration);
  4809.            int timer;
  4810.            unsigned char duration;
  4811.  
  4812. PASCAL:    PROCEDURE UltraStartTimer(Timer    : INTEGER;
  4813.                                      Duration : BYTE);
  4814.  
  4815. Remarks:   This routine  can be  used to  start  up one  of  two available
  4816.            hardware timers.    Timer  #1 is  an  80  microsecond (.00008s)
  4817.            timer.  Timer  #2 is a  320 microsecond (.00032s)  timer.  When
  4818.            starting either timer,  you supply the  # of  counts before the
  4819.            timer 'ticks'.   When the  timer 'ticks',  it ALWAYS  calls the
  4820.            callback routine defined  for it.   If you don't  supply one, a
  4821.            default is used.
  4822.            These timers can be  used to trigger various  real time events.
  4823.            They are  used  extensively  in  music  compostition  programs.
  4824.            Please remember that  the callback  routine is  called directly
  4825.            from the interrupt handler, so you  must be careful what you do
  4826.            in the callback routine.
  4827.            Note that the specified timer  is automatically restarted after
  4828.            it ticks.  Your application must explicitly call UltraStopTimer
  4829.            to shut it off.
  4830.  
  4831. See also:  UltraStopTimer, UltraTimerStopped
  4832.            UltraTimer1Handler, UltraTimer2Handler.
  4833.  
  4834. Example:   Giving Timer 1  a duration  of 10 counts  would make  the timer
  4835.            tick every  800 microseconds  (.0008s).   This would  mean your
  4836.            callback routine is called 1250 times a second.
  4837.  
  4838.  
  4839.  
  4840.  
  4841.  
  4842.  
  4843.  
  4844.  
  4845.  
  4846.  
  4847.  
  4848.  
  4849.  
  4850.  
  4851.  
  4852.  
  4853.  
  4854.  
  4855.  
  4856.  
  4857.  
  4858. ___________________________________________________________________________
  4859.                                                                          74
  4860.  
  4861.  
  4862.  
  4863. Ultrasound Software Development Kit (SDK)                      Version 2.10
  4864. ___________________________________________________________________________
  4865.  
  4866. UltraStartVoice
  4867. _________________________________
  4868.  
  4869. Purpose:   To set up and start a voice playing.
  4870.  
  4871. C:         void UltraStartVoice(voice,begin,start,end,mode);
  4872.            int voice;
  4873.            unsigned long begin;
  4874.            unsigned long start;
  4875.            unsigned long end;
  4876.            unsigned char mode;
  4877.  
  4878. PASCAL:    PROCEDURE UltraStartVoice(Voice  : INTEGER;
  4879.                                      VBegin : LONGINT;
  4880.                                      VStart : LONGINT;
  4881.                                      VEnd   : LONGINT;
  4882.                                      VMode  : BYTE);
  4883.  
  4884. Remarks:   This routine will set up and start up  a voice.  The voice will
  4885.            begin playback  at  the  'begin' and  continue  to  'end'.   If
  4886.            looping is enabled  for this voice,  then it will  then jump to
  4887.            'start' and then continue  to 'end'.  The  method of looping is
  4888.            determined by 'mode'.   See  Appendix C  for the  definition of
  4889.            these bits.
  4890.  
  4891. See also:  UltraSetVoiceEnd, UltraSetLoopMode
  4892.  
  4893.  
  4894.  
  4895. UltraStopTimer
  4896. _________________________________
  4897.  
  4898. Purpose:   To stop a timer which has been previously activated.
  4899.  
  4900. C:         void UltraStopTimer(timer);
  4901.            int timer;
  4902.  
  4903. PASCAL:    PROCEDURE UltraStopTimer(Timer : INTEGER);
  4904.  
  4905. Remarks:   If you  have started  a  timer with  UltraStartTimer,  you will
  4906.            probably  want  to  shut  it  off  before  shutting  down  your
  4907.            application.  If you forget,  UltraClose automatically shuts it
  4908.            down.
  4909.  
  4910. See also:  UltraStartTimer
  4911.  
  4912.  
  4913.  
  4914.  
  4915.  
  4916.  
  4917.  
  4918.  
  4919.  
  4920.  
  4921. ___________________________________________________________________________
  4922.                                                                          75
  4923.  
  4924.  
  4925.  
  4926. Ultrasound Software Development Kit (SDK)                      Version 2.10
  4927. ___________________________________________________________________________
  4928.  
  4929. UltraStopVoice
  4930. _________________________________
  4931.  
  4932. Purpose:   To stop a voice which is playing.
  4933.  
  4934. C:         void UltraStopVoice(voice);
  4935.            int voice;
  4936.  
  4937. PASCAL:    PROCEDURE UltraStopVoice(Voice : INTEGER);
  4938.  
  4939. Remarks:   This routine will stop a voice which is playing at it's current
  4940.            position.  Don't forget that  if a voice is  left at an unknown
  4941.            position, the  data  that is  at  that position  will  still be
  4942.            summed into the final output.
  4943.  
  4944. See also:  UltraStartVoice, UltraSetVoiceEnd
  4945.  
  4946.  
  4947.  
  4948. UltraStopVolume
  4949. _________________________________
  4950.  
  4951. Purpose:   To stop a currently active volume ramp.
  4952.  
  4953. C:         void UltraStopVolume(voice);
  4954.            int voice;
  4955.  
  4956. PASCAL:    PROCEDURE UltraStopVolume(Voice : INTEGER);
  4957.  
  4958. Remarks:   You can use  this routine if  you wish  to stop  an volume ramp
  4959.            after a specified period of time, or you wish to make sure that
  4960.            a volume ramp has stopped.
  4961.  
  4962. See also:  UltraRampVolume, UltraRampLinearVolume
  4963.  
  4964.  
  4965.  
  4966. UltraTimerStopped
  4967. _________________________________
  4968.  
  4969. Purpose:   To check to see if a timer is running.
  4970.  
  4971. C:         int UltraTimerStopped(timer);
  4972.            int timer;
  4973.  
  4974. PASCAL:    FUNCTION UltraTimerStopped(Timer : INTEGER) : BOOLEAN;
  4975.  
  4976. Remarks:   This routine can be used  to see if a  timer is currently being
  4977.            used.
  4978.  
  4979. Returns:   FALSE if still running, TRUE if stopped.
  4980.  
  4981. See also:  UltraStartTimer, UltraStopTimer
  4982.  
  4983.  
  4984. ___________________________________________________________________________
  4985.                                                                          76
  4986.  
  4987.  
  4988.  
  4989. Ultrasound Software Development Kit (SDK)                      Version 2.10
  4990. ___________________________________________________________________________
  4991.  
  4992. UltraTrimJoystick
  4993. _________________________________
  4994.  
  4995. Purpose:   To set the trim voltage on the joystick port.
  4996.  
  4997. C:         void UltraTrimJoystick(value);
  4998.            unsigned char value;
  4999.  
  5000. PASCAL:    PROCEDURE UltraTrimJoystick(JoyVal : BYTE);
  5001.  
  5002. Remarks:   This routine is used to set the speed compensation value on the
  5003.            joystick port on the UltraSound.   The faster the computer, the
  5004.            smaller this value  should be.   This allows  all software that
  5005.            reads the  joystick  to  return  consistent  joystick positions
  5006.            regardless of the speed  of the machine.   This is normally not
  5007.            needed and probably should  never be used  in your application.
  5008.            The utility ULTRAJOY.EXE which is  included with all UltraSound
  5009.            stock software is used to set this value.
  5010.  
  5011.  
  5012. UltraUpload
  5013. _________________________________
  5014.  
  5015. Purpose:   To transfer the contents of a block of DRAM to PC RAM.
  5016.  
  5017. C:         int UltraUpload(dataptr,control,dram_loc,len,wait);
  5018.            void *dataptr;
  5019.            unsigned char control;
  5020.            unsigned long dram_loc;
  5021.            unsigned int len;
  5022.            int wait;
  5023.  
  5024. PASCAL:    FUNCTION UltraUpload(DataPtr  : POINTER;
  5025.                                 Control  : BYTE;
  5026.                                 DRAM_Loc : LONGINT;
  5027.                                 Len      : WORD;
  5028.                                 Wait     : BOOLEAN) : BOOLEAN;
  5029.  
  5030. Remarks:   This  routine  will   retrieve  a   chunk  of  data   from  the
  5031.            UltraSound's DRAM.    It  will transfer  'len'  #  of  bytes to
  5032.            DataPtr (in PC)  from DRAM_loc (in  UltraSound).   If 'Wait' is
  5033.            TRUE, then it  will wait  until the transfer  is complete.   If
  5034.            'Wait' is FALSE, it will return as soon as transfer is started.
  5035.            See Appendix  D for  a definition  of the  control bits.   They
  5036.            specify the type of data being retrieved.
  5037.  
  5038. Returns:   C:      ULTRA_OK if no problem.
  5039.                    DMA_BUSY if DMA Channel is busy.
  5040.  
  5041.            PASCAL: TRUE if transfer was successful.   FALSE otherwise.
  5042.                    If unsuccessful, check UltraErrorStr for the reason.
  5043.  
  5044. See also:  UltraDownload, UltraDRAMDMAWait
  5045.  
  5046.  
  5047. ___________________________________________________________________________
  5048.                                                                          77
  5049.  
  5050.  
  5051.  
  5052. Ultrasound Software Development Kit (SDK)                      Version 2.10
  5053. ___________________________________________________________________________
  5054.  
  5055. UltraVectorVolume
  5056. _________________________________
  5057.  
  5058. Purpose:   To ramp a volume from it's current position to a new value.
  5059.  
  5060. C:         void UltraVectorVolume(voice,end_idx,rate,mode);
  5061.            int voice;
  5062.            unsigned int end;
  5063.            unsigned char rate;
  5064.            unsigned char mode;
  5065.  
  5066. PASCAL:    PROCEDURE UltraVectorVolume(Voice : INTEGER;
  5067.                                        VEnd  : WORD;
  5068.                                        VRate : BYTE;
  5069.                                        VMode : BYTE);
  5070.  
  5071. Remarks:   This routine can be  used to ramp from  an unknown volume value
  5072.            to a new value.  It is useful if you are doing volume envelopes
  5073.            and need to restart the attack/decay sequence at any time.
  5074.  
  5075. See also:  UltraRampVolume, UltraStopVolume
  5076.  
  5077.  
  5078.  
  5079. UltraVersion
  5080. _________________________________
  5081.  
  5082. Purpose:   To return the version of the SDK code being used.
  5083.  
  5084. C:         void UltraVersion(major,minor);
  5085.            int *major;
  5086.            int *minor;
  5087.  
  5088. PASCAL:    PROCEDURE UltraVersion(VAR Major : BYTE;
  5089.                                   VAR Minor : BYTE);
  5090.  
  5091. Remarks:   This routine can be useful to track the version of the SDK that
  5092.            was used in compiling your source code.
  5093.  
  5094. Returns:   Major (1 digit) and minor (2 digits) version of the unit.
  5095.  
  5096. See also:  UltraVersionStr
  5097.  
  5098.  
  5099.  
  5100.  
  5101.  
  5102.  
  5103.  
  5104.  
  5105.  
  5106.  
  5107.  
  5108.  
  5109.  
  5110. ___________________________________________________________________________
  5111.                                                                          78
  5112.  
  5113.  
  5114.  
  5115. Ultrasound Software Development Kit (SDK)                      Version 2.10
  5116. ___________________________________________________________________________
  5117.  
  5118. UltraVersionStr
  5119. _________________________________
  5120.  
  5121. Purpose:   To return the version of the SDK code being used in a string.
  5122.  
  5123. C:         This function is not available.
  5124.  
  5125. PASCAL:    FUNCTION UltraVersionStr : String;
  5126.  
  5127. Remarks:   This routine can be useful to track the version of the SDK that
  5128.            was used in compiling your source code.
  5129.  
  5130. Returns:   Major and minor version of the unit, in string format.
  5131.  
  5132. See also:  UltraVersion
  5133.  
  5134.  
  5135.  
  5136. UltraVoiceStopped
  5137. _________________________________
  5138.  
  5139. Purpose:   To return whether a voice is playing.
  5140.  
  5141. C:         int UltraVoiceStopped(voice);
  5142.            int voice;
  5143.  
  5144. PASCAL:    FUNCTION UltraVoiceStopped(Voice : INTEGER) : BOOLEAN;
  5145.  
  5146. Remarks:   This routine  can  be used  to  see if  a  sample  has finished
  5147.            playing .
  5148.  
  5149. Returns:   TRUE if the voice is stopped, FALSE otherwise.
  5150.  
  5151.  
  5152.  
  5153. UltraVolumeStopped
  5154. _________________________________
  5155.  
  5156. Purpose:   To determine  if  a volume  ramp  is running  for  a particular
  5157.            voice.
  5158.  
  5159. C:         int UltraVolumeStopped(voice);
  5160.            int voice;
  5161.  
  5162. PASCAL:    FUNCTION UltraVolumeStopped(Voice : INTEGER) : BOOLEAN;
  5163.  
  5164. Remarks:   This routine  is used  to determine  the  current state  of the
  5165.            volume of the voice.  It can be used to see if a volume ramp is
  5166.            still running.
  5167.  
  5168. Returns:   TRUE if no volume ramp is running, FALSE otherwise.
  5169.  
  5170. See also:  UltraRampVolume, UltraRampLinearVolume
  5171.  
  5172.  
  5173. ___________________________________________________________________________
  5174.                                                                          79
  5175.  
  5176.  
  5177.  
  5178. Ultrasound Software Development Kit (SDK)                      Version 2.10
  5179. ___________________________________________________________________________
  5180.  
  5181. UltraWaitDRAMDMA
  5182. _________________________________
  5183.  
  5184. Purpose:   To wait for a DRAM DMA transfer to complete.
  5185.  
  5186. C:         void UltraWaitDramDMA(void);
  5187.  
  5188. PASCAL:    PROCEDURE UltraWaitDRAMDMA;
  5189.  
  5190. Remarks:   If a DMA transfer to/from DRAM is  started but told not to wait
  5191.            for it to complete, this  routine can be used  to wait until it
  5192.            has completed.
  5193.  
  5194. See also:  UltraDownload, UltraUpload
  5195.  
  5196.  
  5197.  
  5198. UltraWaitRecordDMA
  5199. _________________________________
  5200.  
  5201. Purpose:   To wait for a recording DMA transfer to complete.
  5202.  
  5203. C:         void UltraWaitRecordDMA(void);
  5204.  
  5205. PASCAL:    PROCEDURE UltraWaitRecordDMA;
  5206.  
  5207. Remarks:   This can be  used to let  an application wait  until a complete
  5208.            sample is finished being acquired.
  5209.  
  5210. See also:  UltraRecordData
  5211.  
  5212.  
  5213.  
  5214.  
  5215.  
  5216.  
  5217.  
  5218.  
  5219.  
  5220.  
  5221.  
  5222.  
  5223.  
  5224.  
  5225.  
  5226.  
  5227.  
  5228.  
  5229.  
  5230.  
  5231.  
  5232.  
  5233.  
  5234.  
  5235.  
  5236. ___________________________________________________________________________
  5237.                                                                          80
  5238.  
  5239.  
  5240.  
  5241. Ultrasound Software Development Kit (SDK)                      Version 2.10
  5242. ___________________________________________________________________________
  5243.  
  5244. UltraAllocVoice
  5245. _________________________________
  5246.  
  5247. Purpose:   To allocate a new voice not currently being used.
  5248.  
  5249. C:         int UltraAllocVoice(voice_num,new_num);
  5250.            int voice_num;
  5251.            int *new_num;
  5252.  
  5253. PASCAL:    FUNCTION UltraAllocVoice(VAR Voice_Num : INTEGER) : BOOLEAN;
  5254.  
  5255. Remarks:   This routine will return  a voice for your  application to use.
  5256.            If you supply a voice number,  it will attempt to allocate that
  5257.            particular voice. If  you pass  a -1 for  the voice  number, it
  5258.            will return  the  next  free  voice.  This  routine  will  only
  5259.            allocate voices up to  the # of active  voices specified in the
  5260.            UltraOpen function.
  5261.  
  5262. Returns:   C: ULTRA_OK             Got a voice ok
  5263.               VOICE_NOT_FREE       Can't get the voice or none left.
  5264.               VOICE_OUT_OF_RANGE   Specified voice out of range.
  5265.  
  5266.            PASCAL: TRUE if there was no problem allocating the voice.
  5267.                    If FALSE, check UltraErrorStr for the reason.
  5268.  
  5269. See also:  UltraClearVoices, UltraFreeVoices
  5270.  
  5271.  
  5272.  
  5273. UltraClearVoices
  5274. _________________________________
  5275.  
  5276. Purpose:   To reset all voices to an un-allocated state.
  5277.  
  5278. C:         void UltraClearVoices(void);
  5279.  
  5280. PASCAL:    PROCEDURE UltraClearVoices;
  5281.  
  5282. Remarks:   This routine will  deallocate all  previously allocated voices.
  5283.            It  would  be  advisable  to  call  this  before  using  either
  5284.            UltraAllocVoice or UltraFreeVoice.
  5285.  
  5286. See also:  UltraAllocVoice, UltraFreeVoice.
  5287.  
  5288.  
  5289.  
  5290.  
  5291.  
  5292.  
  5293.  
  5294.  
  5295.  
  5296.  
  5297.  
  5298.  
  5299. ___________________________________________________________________________
  5300.                                                                          81
  5301.  
  5302.  
  5303.  
  5304. Ultrasound Software Development Kit (SDK)                      Version 2.10
  5305. ___________________________________________________________________________
  5306.  
  5307. UltraFreeVoice
  5308. _________________________________
  5309.  
  5310. Purpose:   To free up an allocated voice.
  5311.  
  5312. C:         void UltraFreeVoice(voice_num);
  5313.            int voice_num;
  5314.  
  5315. PASCAL:    PROCEDURE UltraFreeVoice(Voice_Num : INTEGER);
  5316.  
  5317. Remarks:   This routine will  free up  a previously allocated  voice. This
  5318.            should be used when your application  no longer needs the voice
  5319.            so it can be re-allocated at another time.
  5320.  
  5321. See also:  UltraClearVoices, UltraAllocVoice.
  5322.  
  5323.  
  5324.  
  5325. UltraVoiceOff
  5326. _________________________________
  5327.  
  5328. Purpose:   To allow flexibility in stopping a voice.
  5329.  
  5330. C:         void UltraVoiceOff(voice,end);
  5331.            int voice;
  5332.            int end;
  5333.  
  5334. PASCAL:    PROCEDURE UltraVoiceOff(Voice : INTEGER;
  5335.                                    VEnd  : BOOLEAN);
  5336.  
  5337. Remarks:   This routine will  either stop  a voice  immediately or  let it
  5338.            finish its current loop.  If 'VEnd'  is FALSE then it will stop
  5339.            abruptly,  otherwise   it   will  finish   the   current  loop.
  5340.            UltraReadVoice could be called  afterwards if you  need to know
  5341.            where the loop finished.
  5342.            If used with  UltraSetVoiceEnd, you  could implement  a sampled
  5343.            decay on the end of your sample.  This would occur if your loop
  5344.            point was not at the end of your  data, and you changed the end
  5345.            point to the real end  point of your data  and then called this
  5346.            routine with VEnd set to TRUE.
  5347.  
  5348. See also:  UltraReadVoice, UltraSetVoiceEnd
  5349.  
  5350.  
  5351.  
  5352.  
  5353.  
  5354.  
  5355.  
  5356.  
  5357.  
  5358.  
  5359.  
  5360.  
  5361.  
  5362. ___________________________________________________________________________
  5363.                                                                          82
  5364.  
  5365.  
  5366.  
  5367. Ultrasound Software Development Kit (SDK)                      Version 2.10
  5368. ___________________________________________________________________________
  5369.  
  5370. UltraVoiceOn
  5371. _________________________________
  5372.  
  5373. Purpose:   To turn a voice on at a given frequency.
  5374.  
  5375. C:         void UltraVoiceOn(voice,begin,s_loop,e_loop,control,freq);
  5376.            int voice;
  5377.            unsigned long begin;
  5378.            unsigned long s_loop;
  5379.            unsigned long e_loop;
  5380.            unsigned char control;
  5381.            unsigned long freq;
  5382.  
  5383. PASCAL:    PROCEDURE UltraVoiceOn(Voice      : INTEGER;
  5384.                                   VBegin     : LONGINT;
  5385.                                   Start_Loop : LONGINT;
  5386.                                   End_Loop   : LONGINT;
  5387.                                   Control    : BYTE;
  5388.                                   Freq       : LONGINT);
  5389.  
  5390. Remarks:   This routine just sets the frequency with UltraSetFrequency and
  5391.            then calls UltraStartVoice.
  5392.  
  5393. See also:  UltraSetFrequency, UltraStartVoice
  5394.  
  5395.  
  5396.  
  5397. UltraSetLinearVolume
  5398. _________________________________
  5399.  
  5400. Purpose:   To set a voice's volume to a linearized value.
  5401.  
  5402. C:         void UltraSetLinearVolume(voice,index);
  5403.            int voice;
  5404.            int index;
  5405.  
  5406. PASCAL:    PROCEDURE UltraSetLinearVolume(Voice : INTEGER;
  5407.                                           Index : INTEGER);
  5408.  
  5409. Remarks:   This routine indexes into a table  to translate a linear volume
  5410.            (0-511)  to  a   logarithmic  one  (0-4095),   and  then  calls
  5411.            UltraSetVolume.
  5412.  
  5413. See also:  UltraSetVolume
  5414.  
  5415.  
  5416.  
  5417.  
  5418.  
  5419.  
  5420.  
  5421.  
  5422.  
  5423.  
  5424.  
  5425. ___________________________________________________________________________
  5426.                                                                          83
  5427.  
  5428.  
  5429.  
  5430. Ultrasound Software Development Kit (SDK)                      Version 2.10
  5431. ___________________________________________________________________________
  5432.  
  5433. UltraReadLinearVolume
  5434. _________________________________
  5435.  
  5436. Purpose:   To read a voice's volume as a linear value.
  5437.  
  5438. C:         This function is not available.
  5439.  
  5440. PASCAL:    FUNCTION UltraReadLinearVolume(Voice : INTEGER) : INTEGER;
  5441.  
  5442. Remarks:   This routine  indexes  into  a  table  to  translate  a  0-4095
  5443.            logarithmic volume to a 0-511 linear volume.
  5444.  
  5445. Returns:   Linear Volume Value (0-511).
  5446.  
  5447. See also:  UltraSetVolume, UltraSetLinearVolume
  5448.  
  5449.  
  5450.  
  5451. UltraRampLinearVolume
  5452. _________________________________
  5453.  
  5454. Purpose:   To ramp a voice's volume between linear volume values.
  5455.  
  5456. C:         void UltraRampLinearVolume(voice,start,end,msecs,mode);
  5457.            int voice;
  5458.            unsigned int start;
  5459.            unsigned int end;
  5460.            unsigned long msecs;
  5461.            unsigned char mode;
  5462.  
  5463. PASCAL:    PROCEDURE UltraRampLinearVolume(Voice     : INTEGER;
  5464.                                            Start_Idx : WORD;
  5465.                                            End_Idx   : WORD;
  5466.                                            Msecs     : LONGINT;
  5467.                                            VMode     : BYTE);
  5468.  
  5469. Remarks:   This routine is  used to  ramp between linear  volume settings.
  5470.            It uses the  same method  as UltraSetLinearVolume  to determine
  5471.            the  actual   volume   settings   to   use,   and  then   calls
  5472.            UltraRampVolume.
  5473.  
  5474. See also:  UltraRampVolume, UltraSetLinearVolume
  5475.  
  5476.  
  5477.  
  5478.  
  5479.  
  5480.  
  5481.  
  5482.  
  5483.  
  5484.  
  5485.  
  5486.  
  5487.  
  5488. ___________________________________________________________________________
  5489.                                                                          84
  5490.  
  5491.  
  5492.  
  5493. Ultrasound Software Development Kit (SDK)                      Version 2.10
  5494. ___________________________________________________________________________
  5495.  
  5496. UltraVectorLinearVolume
  5497. _________________________________
  5498.  
  5499. Purpose:   To ramp a linear  volume from it's current  position to a known
  5500.            end point.
  5501.  
  5502. C:         void UltraVectorLinearVolume(voice,end,rate,mode)
  5503.            int voice;
  5504.            unsigned int end;
  5505.            unsigned char rate;
  5506.            unsigned char mode;
  5507.  
  5508. PASCAL:    PROCEDURE UltraVectorLinearVolume(Voice   : INTEGER;
  5509.                                              End_Idx : WORD;
  5510.                                              VRate   : BYTE;
  5511.                                              VMode   : BYTE);
  5512.  
  5513. Remarks:   This routine can be  used to ramp  from an unknown  volume to a
  5514.            new linear  volume.   It  is  useful if  you  are  doing volume
  5515.            envelopes and need to restart the  attack/decay sequence at any
  5516.            time.  It can also  produce a smoother ramp  from one volume to
  5517.            another, since arbitrarily  setting a  volume that is  far away
  5518.            from the current volume can cause 'pops'.
  5519.  
  5520. See also:  UltraSetLinearVolume, UltraReadLinearVolume
  5521.  
  5522.  
  5523.  
  5524.  
  5525.  
  5526.  
  5527.  
  5528.  
  5529.  
  5530.  
  5531.  
  5532.  
  5533.  
  5534.  
  5535.  
  5536.  
  5537.  
  5538.  
  5539.  
  5540.  
  5541.  
  5542.  
  5543.  
  5544.  
  5545.  
  5546.  
  5547.  
  5548.  
  5549.  
  5550.  
  5551. ___________________________________________________________________________
  5552.                                                                          85
  5553.  
  5554.  
  5555.  
  5556. Ultrasound Software Development Kit (SDK)                      Version 2.10
  5557. ___________________________________________________________________________
  5558.  
  5559.                      Chapter 5 - Focal Point 3D Sound
  5560.  
  5561. 5.0 Introduction
  5562.  
  5563. Three dimensional audio on the UltraSound is achieved by a technique called
  5564. binaural representation.    Basically, this  means  that a  mono  sound  is
  5565. 'shaped' in such a way that when it is presented to the right and left ears
  5566. properly, the sound seems  to come from  the proper place  in space.   This
  5567. technique is  also  called  convolution.   This  is  done  thru  algorithms
  5568. developed by Focal Point(tm) 3D Audio.  Focal Point has provided a  utility
  5569. (called FP3D.EXE) to  convert a mono  sound file to  a 3D  file capable  of
  5570. being played on an UltraSound.  The basic concept is that the mono sound is
  5571. processed in such  a way  that the file  that is  output contains  up to  6
  5572. tracks of sound.  When the sound  is played back, the volumes and  balances
  5573. are adjusted to make the sound appear to originate from anywhere in the  3D
  5574. space.  It  is possible to  create files that  only have 4  tracks and  can
  5575. therefore only be  positioned in 2  dimensions.  This  may be adequate  for
  5576. many applications and it will make the resultant file smaller.
  5577.  
  5578. There are 2 types of 3D sound that an  application might want to use.   The
  5579. first is a sound  effect.  This is  a sound that  can be completely  loaded
  5580. into DRAM and played  and positioned at any  time.  It  is used for  things
  5581. like gunshots, cars etc.   These can  be looped or  non-looped.  The  other
  5582. type of sound is a sound track.  This is for a very long sound that  cannot
  5583. be loaded in DRAM all at once.  The implementation of each of these methods
  5584. is very different.   A  sound effect is  implemented using  a blocked  data
  5585. format.  This means  that each track's data  is in a block  of its own.   A
  5586. sound track uses interleaved data.  This means that all the track's data is
  5587. interleaved together.  For example, a blocked file would look like this:
  5588.  
  5589. HEADER FFFFFRRRRRBBBBBLLLLLUUUUUDDDDD....
  5590.  
  5591. whereas an interleaved file would look like this:
  5592.  
  5593. HEADER FRBLUDFRBLUDFRBLUDFRBLUDFRBLUD...
  5594.  
  5595. where
  5596.  
  5597. F = Front Track     L = Left Track
  5598. R = Right Track   U = Up Track
  5599. B = Behind Track   D = Down Track
  5600.  
  5601. Both of these methods have  their individual advantages and  disadvantages.
  5602. First, the interleaved method makes it very easy  to read in the data in  a
  5603. continuous stream since it will look the same all the way through the file.
  5604. It is also faster to read 60K of data once  rather than 6 10K reads.   This
  5605. makes it very useful for a sound track.   However, one drawback is that  it
  5606. has a very limited number of frequencies that  it will run at.  The  reason
  5607. for this is  rather difficult to  explain, but it  pertains to getting  the
  5608. UltraSound's voices to play every 4th (or 5th, etc) sample.  The UltraSound
  5609. normally would interpolate between  data points but it  can't do that  here
  5610. because the adjacent data points are not in the same track.
  5611.  
  5612.  
  5613.  
  5614. ___________________________________________________________________________
  5615.                                                                          86
  5616.  
  5617.  
  5618.  
  5619. Ultrasound Software Development Kit (SDK)                      Version 2.10
  5620. ___________________________________________________________________________
  5621.  
  5622. If you want to run at 22050 Hz, then you need to have only 28 active voices
  5623. to accomplish this.  If you want to play a track at 44100 Hz, you must have
  5624. only 14 active voices.  Blocked data doesn't have this problem.  Since  the
  5625. data is NOT interleaved, but in  a block of contiguous DRAM, its  frequency
  5626. can be  adjusted to  any value.   This  is usually  very useful  for  sound
  5627. effects (rev'ing  engines etc).   Also,  since the  data is  blocked,  each
  5628. track's data can be allocated separately  and can therefore be up to  256K.
  5629. An interleaved file must fit  into 1 256K bank  since we cannot play  16bit
  5630. data across a 256K bank.  See the two example 3D programs provided  (PLAY3D
  5631. and PLAY3DI) for ideas on how to implement 3D sound into you applications.
  5632.  
  5633.  
  5634. 5.1  Creating 3D file
  5635.  
  5636. Please read the readme.3D file for information on creating a 3D file.
  5637.  
  5638.  
  5639. 5.2  3D Sound Routines
  5640.  
  5641. UltraAbsPosition
  5642. _________________________________
  5643.  
  5644. Purpose:   To place a sound using integer Cartesian coordinates.
  5645.  
  5646. C:         void UltraAbsPosition3D(sound,xpos,ypos,zpos);
  5647.            SOUND_3D *sound;
  5648.            int xpos;
  5649.            int ypos;
  5650.            int zpos;
  5651.  
  5652. PASCAL:    PROCEDURE UltraAbsPosition3D(VAR Sound : SOUND_3D;
  5653.                                             XPos  : INTEGER;
  5654.                                             YPos  : INTEGER;
  5655.                                             ZPos  : INTEGER);
  5656.  
  5657. Remarks:   This routine  will position  a sound  using  standard cartesian
  5658.            coordinates. The X position  range is from -511  (left) to +511
  5659.            (right). The Y position  is from -511 (below)  to +511 (above).
  5660.            The Z position is from -511 (behind) to +511 (ahead). The X and
  5661.            Z positions determine the azimuth position and Y determines the
  5662.            elevation. The distance  away from  the listener  is determined
  5663.            using    trigonometry.     Once    these     are    determined,
  5664.            UltraAngPosition3D is called.
  5665.  
  5666.            If the distance  is calculated  to be greater  than 511,  it is
  5667.            clipped to 511. Also, if the distance is calculated to be 0, no
  5668.            positioning is  done since  the  origin is  undefined.  (i.e. A
  5669.            sound cannot be generated INSIDE your head (origin)).
  5670.  
  5671.            C users should  be careful when  using this  routine, since the
  5672.            trig functions will be needed from the C libraries.
  5673.  
  5674. See also:  UltraAngPosition3D
  5675.  
  5676.  
  5677. ___________________________________________________________________________
  5678.                                                                          87
  5679.  
  5680.  
  5681.  
  5682. Ultrasound Software Development Kit (SDK)                      Version 2.10
  5683. ___________________________________________________________________________
  5684.  
  5685. UltraAngPosition3D
  5686. _________________________________
  5687.  
  5688. Purpose:   To position a sound using integer polar coordinates.
  5689.  
  5690. C:         void UltraAngPosition3D(sound,azimuth,elevation,volume);
  5691.            SOUND_3D *sound;
  5692.            int azimuth;
  5693.            int elevation;
  5694.            int volume;
  5695.  
  5696. PASCAL:    PROCEDURE UltraAngPosition3D(VAR Sound     : SOUND_3D;
  5697.                                             AZIMuth   : INTEGER;
  5698.                                             Elevation : INTEGER;
  5699.                                             Vol_Dist  : INTEGER);
  5700.  
  5701. Remarks:   This routine will position a 3D  sound using polar coordinates.
  5702.            The azimuth and elevation are specified  in degrees. Azimuth is
  5703.            the angle in the horizontal plane. Straight ahead is 0 degrees,
  5704.            90 degrees is to the right, -90 degrees  is to the left and 180
  5705.            (or -180) is directly  behind you. If an  angle larger than 180
  5706.            or smaller that -180 is specified,  it is converted to its -180
  5707.            to 180 equivalent. For example, 270  degrees is equivalent to -
  5708.            90 degrees. Elevation is the angle  of elevation above or below
  5709.            the horizontal plane. 0 degrees is  no elevation, 90 degrees is
  5710.            straight up, and -90 is straight down. Any angle larger than 90
  5711.            or smaller that -90 is ignored.
  5712.  
  5713.            If more precision is needed,  use UltraAngFltPosition3D so that
  5714.            floating point  arithmetic is  used.   Since that  routine uses
  5715.            floating point functions (slow), your  application may not want
  5716.            to use it.
  5717.  
  5718. See also:  UltraAbsPosition3D
  5719.  
  5720.  
  5721.  
  5722.  
  5723.  
  5724.  
  5725.  
  5726.  
  5727.  
  5728.  
  5729.  
  5730.  
  5731.  
  5732.  
  5733.  
  5734.  
  5735.  
  5736.  
  5737.  
  5738.  
  5739.  
  5740. ___________________________________________________________________________
  5741.                                                                          88
  5742.  
  5743.  
  5744.  
  5745. Ultrasound Software Development Kit (SDK)                      Version 2.10
  5746. ___________________________________________________________________________
  5747.  
  5748. UltraAngFltPosition3D
  5749. _________________________________
  5750.  
  5751. Purpose:   To position a sound using floating point polar coordinates.
  5752.  
  5753. C:         void UltraAngFltPosition3D(sound,azimuth,elevation,volume);
  5754.            SOUND_3D *sound;
  5755.            double azimuth;
  5756.            double elevation;
  5757.            int volume;
  5758.  
  5759. PASCAL:    PROCEDURE UltraAngFltPosition3D(VAR Sound     : SOUND_3D;
  5760.                                                AZIMuth   : DOUBLE;
  5761.                                                Elevation : DOUBLE;
  5762.                                                Vol_Dist  : INTEGER);
  5763.  
  5764. Remarks:   This routine will position a 3D  sound using polar coordinates.
  5765.            The azimuth  and elevation  are  specified as    floating point
  5766.            numbers in degrees. For example, 45  and one half degrees would
  5767.            be specified as  45.5. Azimuth is  the angle  in the horizontal
  5768.            plane. Straight ahead is 0 degrees, 90 degrees is to the right,
  5769.            -90 degrees is to the left and 180 (or -180) is directly behind
  5770.            you. If  an  angle larger  than  180 or  smaller  that  -180 is
  5771.            specified, it is converted  to its -180 to  180 equivalent. For
  5772.            example, 270 degrees is equivalent to -90 degrees. Elevation is
  5773.            the angle above or below the  horizontal plane. 0 degrees is no
  5774.            elevation, 90 degrees is straight up, and -90 is straight down.
  5775.            Any angle larger than 90 or smaller that -90 is ignored.
  5776.  
  5777.            If your application  does not  need to  use the  floating point
  5778.            routine, it  is advisable  to use  UltraAngPosition  because it
  5779.            avoids using some floating-point functions (which are slow).
  5780.  
  5781.  
  5782.  
  5783. UltraCloseDup3D
  5784. _________________________________
  5785.  
  5786. Purpose:   To close a duplicated 3D sound effect.
  5787.  
  5788. C:         void UltraCloseDup3D(sound);
  5789.            SOUND_3D *sound;
  5790.  
  5791. PASCAL:    PROCEDURE UltraCloseDup3D(VAR Sound : SOUND_3D);
  5792.  
  5793. Remarks:   This routine must be  used to free up  the resources associated
  5794.            with a duplicated 3D effect. This routine will only release the
  5795.            voices used by the duplicated effect, not the DRAM allocated by
  5796.            the original effect. The original effect  should be closed with
  5797.            UltraUnLoad3DEffect.
  5798.  
  5799. See also:  UltraDup3D, UltraUnLoad3DEffect.
  5800.  
  5801.  
  5802.  
  5803. ___________________________________________________________________________
  5804.                                                                          89
  5805.  
  5806.  
  5807.  
  5808. Ultrasound Software Development Kit (SDK)                      Version 2.10
  5809. ___________________________________________________________________________
  5810.  
  5811. UltrDup3D
  5812. _________________________________
  5813.  
  5814. Purpose:   To copy a 3D sound effect.
  5815.  
  5816. C:         int UltraDup3D(old,new);
  5817.            SOUND_3D *old;
  5818.            SOUND_3D *new;
  5819.  
  5820. PASCAL:    FUNCTION  UltraDup3D(VAR Current : SOUND_3D;
  5821.                                 VAR Sound   : SOUND_3D) : BOOLEAN;
  5822.  
  5823. Remarks:   This routine is very useful  if you want to  use the same sound
  5824.            effect in multiple places  at once. This allows  you to use the
  5825.            same DRAM data and  just allocate some more  voices to move the
  5826.            sound. This helps  to save DRAM  space. Make sure  that you use
  5827.            UltraCloseDup3D to  free the  voices,  NOT UltraUnLoad3DEffect.
  5828.            UltraUnLoad3DEffect will release  all the  DRAM for  the sound.
  5829.            This new effect  can be passed  to any other  routines the same
  5830.            way the original effect is.
  5831.  
  5832. Returns:   C:  ULTRA_OK        No Error
  5833.                NO_FREE_VOICES  Not enough voices to make new handle
  5834.  
  5835.            PASCAL: TRUE if duplication successful.
  5836.                    If FALSE, check UltraErrorStr for the reason.
  5837.  
  5838. See also:  UltraCloseDup3D
  5839.  
  5840.  
  5841.  
  5842.  
  5843.  
  5844.  
  5845.  
  5846.  
  5847.  
  5848.  
  5849.  
  5850.  
  5851.  
  5852.  
  5853.  
  5854.  
  5855.  
  5856.  
  5857.  
  5858.  
  5859.  
  5860.  
  5861.  
  5862.  
  5863.  
  5864.  
  5865.  
  5866. ___________________________________________________________________________
  5867.                                                                          90
  5868.  
  5869.  
  5870.  
  5871. Ultrasound Software Development Kit (SDK)                      Version 2.10
  5872. ___________________________________________________________________________
  5873.  
  5874. UltraLoad3DEffect
  5875. _________________________________
  5876.  
  5877. Purpose:   To load a 3D effect from the disk into DRAM.
  5878.  
  5879. C:         int UltraLoad3DEffect(sound,filename,pc_buffer,size);
  5880.            SOUND_3D *sound;
  5881.            char *filename;
  5882.            void far *pc_buffer;
  5883.            unsigned int size;
  5884.  
  5885. PASCAL:    FUNCTION  UltraLoad3DEffect(VAR Sound     : SOUND_3D;
  5886.                                        VAR FileName  : STRING;
  5887.                                            PC_Buffer : POINTER;
  5888.                                            Size      : WORD) : BOOLEAN;
  5889.  
  5890. Remarks:   This routine is used  to load a 3D  sound into the  DRAM on the
  5891.            UltraSound. It will  allocate all  necessary resources  so that
  5892.            UltraStart3D can be  called later. As  many buffers  of DRAM as
  5893.            needed will  be  allocated  along  with  the  proper number  of
  5894.            voices.  These  resources  will  be  freed  up  when  you  call
  5895.            UltraUnLoad3DEffect. The  file  specified  MUST  be  a properly
  5896.            formatted or the  routine will  fail. This  means that  it must
  5897.            have the proper header and 3D data  in it. The 'pc_buffer' is a
  5898.            buffer supplied by your  application for this  routine's use to
  5899.            download data into the UltraSound. The  'size' parameter is the
  5900.            size of the 'pc_buffer'. The larger  this buffer is, the faster
  5901.            it will download.
  5902.  
  5903. Returns:   C: ULTRA_OK         No error
  5904.               NO_3D_FILE       3D file not found
  5905.               BAD_3D_HDR       3D header is bad
  5906.               NO_3D_HDR        File doesn't have a valid header
  5907.               NOT_BLOCK_DATA   File is not in blocked format
  5908.               NO_FREE_VOICES   Not enough free voices
  5909.               BAD_FILE_DATA    Not enough data or bad file
  5910.               CORRUPT_MEM      Memory structs have been corrupted
  5911.               DMA_BUSY         DMA channel busy
  5912.  
  5913.            PASCAL: TRUE if the file could be loaded.
  5914.                    If FALSE check UltraErrorStr for the reason.
  5915.  
  5916. See also:  UltraMemAlloc, UltraVoiceAlloc, UltraDownload
  5917.  
  5918.  
  5919.  
  5920.  
  5921.  
  5922.  
  5923.  
  5924.  
  5925.  
  5926.  
  5927.  
  5928.  
  5929. ___________________________________________________________________________
  5930.                                                                          91
  5931.  
  5932.  
  5933.  
  5934. Ultrasound Software Development Kit (SDK)                      Version 2.10
  5935. ___________________________________________________________________________
  5936.  
  5937. UltraSetFreq3D
  5938. _________________________________
  5939.  
  5940. Purpose:   To set the frequency of a 3D sound effect.
  5941.  
  5942. C:         void UltraSetFreq3D(sound,frequency);
  5943.            SOUND_3D *sound;
  5944.            unsigned long frequency;
  5945.  
  5946. PASCAL:    FUNCTION  UltraSetFreq3D(VAR Sound     : SOUND_3D;
  5947.                                         Frequency : LONGINT) : BOOLEAN;
  5948.  
  5949. Remarks:   This routine will allow you to  alter the frequency that the 3D
  5950.            sound is using. This allows  you to do pitch  shifting to get a
  5951.            doppler shift type  effect. This  routine can  only be  done on
  5952.            blocked data.
  5953.  
  5954. Returns:   C: ULTRA_OK          No problem
  5955.               NOT_BLOCKED_DATA  Can't change freq of interleaved data
  5956.  
  5957.            PASCAL: TRUE if the frequency was changed ok.
  5958.                    If FALSE, check UltraErrorStr for the reason.
  5959.  
  5960.  
  5961.  
  5962. UltraRelease3DInterleave
  5963. _________________________________
  5964.  
  5965. Purpose:   To release 3D resources for an interleaved effect.
  5966.  
  5967. C:         void UltraRelease3DInterleave(sound)
  5968.            SOUND_3D *sound;
  5969.  
  5970. PASCAL:    PROCEDURE UltraRelease3DInterleave(VAR Sound : SOUND_3D);
  5971.  
  5972. Remarks:   This routines will release the DRAM and voices allocated for an
  5973.            interleaved sound track.
  5974.  
  5975. See also:  UltraSetup3DInterleave
  5976.  
  5977.  
  5978.  
  5979.  
  5980.  
  5981.  
  5982.  
  5983.  
  5984.  
  5985.  
  5986.  
  5987.  
  5988.  
  5989.  
  5990.  
  5991.  
  5992. ___________________________________________________________________________
  5993.                                                                          92
  5994.  
  5995.  
  5996.  
  5997. Ultrasound Software Development Kit (SDK)                      Version 2.10
  5998. ___________________________________________________________________________
  5999.  
  6000. UltraSetup3DInterleave
  6001. _________________________________
  6002.  
  6003. Purpose:   To set up for an interleaved 3D sound effect.
  6004.  
  6005. C:         int UltraSetup3DInterleave(sound,filename,size);
  6006.            SOUND_3D *sound;
  6007.            char *filename;
  6008.            unsigned long size;
  6009.  
  6010. PASCAL:    FUNCTION UltraSetup3DInterleave(VAR Sound    : SOUND_3D;
  6011.                                            VAR FileName : STRING;
  6012.                                            Size : LONGINT) : BOOLEAN;
  6013.  
  6014. Remarks:   This routine will allocate  the voices and  memory necessary to
  6015.            play back an interleaved 3D sound. It  will NOT load any of the
  6016.            file data into DRAM. Your application  is responsible for that.
  6017.            It  will  open  the   file,  read  the   header,  allocate  the
  6018.            appropriate resources, and set up the begin, start and end loop
  6019.            points for each  voice. Since  the sound  is   interleaved, the
  6020.            loop points are staggared appropriately.
  6021.  
  6022. Returns:   C: ULTRA_OK             No error
  6023.               NO_3D_FILE           3D file not found
  6024.               BAD_3D_HDR           3D header is bad
  6025.               NO_3D_HDR            File doesn't have a valid header
  6026.               NOT_INTERLEAVED_DATA File in blocked format
  6027.               NO_FREE_VOICES       Not enough free voices
  6028.               BAD_FILE_DATA        Not enough data or bad file
  6029.               CORRUPT_MEM          Memory structs have been corrupted
  6030.  
  6031.            PASCAL: TRUE if the file could be read successfully.
  6032.                    If FALSE, check UltraErrorStr for the reason.
  6033.  
  6034. See also:  UltraLoad3DEffect
  6035.  
  6036.  
  6037.  
  6038. UltraStart3D
  6039. _________________________________
  6040.  
  6041. Purpose:   To start a 3D sound which has been loaded.
  6042.  
  6043. C:         void UltraStart3D(sound);
  6044.            SOUND_3D *sound;
  6045.  
  6046. PASCAL:    PROCEDURE UltraStart3D(VAR Sound : SOUND_3D);
  6047.  
  6048. Remarks:   This routine will start a 3D sound. If  you want it to begin at
  6049.            a specific point in space, be  sure that you position it first.
  6050.            It is not necessary to stop the sound before starting it again.
  6051.  
  6052. See also:  UltraStart3D
  6053.  
  6054.  
  6055. ___________________________________________________________________________
  6056.                                                                          93
  6057.  
  6058.  
  6059.  
  6060. Ultrasound Software Development Kit (SDK)                      Version 2.10
  6061. ___________________________________________________________________________
  6062.  
  6063. UltraStop3D
  6064. _________________________________
  6065.  
  6066. Purpose:   To stop a 3D sound which is playing.
  6067.  
  6068. C:         void UltraStop3D(sound,abruptly);
  6069.            SOUND_3D *sound;
  6070.            int abruptly;
  6071.  
  6072. PASCAL:    PROCEDURE UltraStop3D(VAR Sound    : SOUND_3D;
  6073.                                      Abruptly : BOOLEAN);
  6074.  
  6075. Remarks:   This routine will stop a 3D sound. There are two ways to stop a
  6076.            sound: if the 'abruptly' flag is TRUE, then the sound will shut
  6077.            off immediately; if it is FALSE,  then the sound will be ramped
  6078.            down very  quickly.  The  second method  will  give  a smoother
  6079.            transition.
  6080.  
  6081.  
  6082.  
  6083. UltraUnLoad3DEffect
  6084. _________________________________
  6085.  
  6086. Purpose:   To free resources used by a 3D effect.
  6087.  
  6088. C:         void UltraUnLoad3DEffect(sound);
  6089.            SOUND_3D *sound;
  6090.  
  6091. PASCAL:    PROCEDURE UltraUnLoad3DEffect(VAR Sound : SOUND_3D);
  6092.  
  6093. Remarks:   This routine is  used to  free up all  the resources  (voices &
  6094.            DRAM) that a 3D  sound   uses.  Since a 3D  sound can use a lot
  6095.            of  the   voices   & DRAM,  you should  free up  the  resources
  6096.            whenever you can.
  6097.  
  6098. See also:  UltraLoad3DEffect
  6099.  
  6100.  
  6101.  
  6102.  
  6103.  
  6104.  
  6105.  
  6106.  
  6107.  
  6108.  
  6109.  
  6110.  
  6111.  
  6112.  
  6113.  
  6114.  
  6115.  
  6116.  
  6117.  
  6118. ___________________________________________________________________________
  6119.                                                                          94
  6120.  
  6121.  
  6122.  
  6123. Ultrasound Software Development Kit (SDK)                      Version 2.10
  6124. ___________________________________________________________________________
  6125.  
  6126.                          Appendix A - Error Codes
  6127.  
  6128. ======
  6129.   C:
  6130. ======
  6131.  
  6132. Main routines: (these are defined in ULTRAERR.H)
  6133.  
  6134.   ULTRA_OK           1   No error
  6135.   BAD_NUM_OF_VOICES  2   must be 14-32
  6136.   NO_MEMORY          3   Not enough free DRAM left
  6137.   CORRUPT_MEM        4   memory structures are corrupt
  6138.   NO_ULTRA           5   Can't find an UltraSound
  6139.   DMA_BUSY           6   This DMA channel is still busy
  6140.   BAD_DMA_ADDR       7   auto init across page boundaries
  6141.   VOICE_OUT_OF_RANGE 8   allocate a voice past # active
  6142.   VOICE_NOT_FREE     9   voice has already been allocated
  6143.   NO_FREE_VOICES     10   not any voices free
  6144.  
  6145. 3D functions: (these are defined in THREED.H)
  6146.  
  6147.   NO_3D_FILE             101   Can't open file
  6148.   BAD_3D_HDR             102   Header for file is corrupt/non-existent
  6149.   NO_DRAM_3D             103   Not enough room for this sound
  6150.   NO_3D_HDR              104   No header on this file
  6151.   NOT_BLOCK_DATA         105   data not in block format
  6152.   BAD_FILE_DATA          106   not enough data as header says
  6153.   NOT_INTERLEAVED_DATA   107  data not in interleaved format
  6154.   BAD_3D_FREQ            108  invalid freq. for interleaved 3D data
  6155.  
  6156.  
  6157.  
  6158. =========
  6159.  PASCAL:
  6160. =========
  6161.  
  6162. Please see the discussion of the PASCAL error handling techniques at the
  6163. end of section 1.8.1.
  6164.  
  6165.  
  6166.  
  6167.  
  6168.  
  6169.  
  6170.  
  6171.  
  6172.  
  6173.  
  6174.  
  6175.  
  6176.  
  6177.  
  6178.  
  6179.  
  6180.  
  6181. ___________________________________________________________________________
  6182.                                                                          95
  6183.  
  6184.  
  6185.  
  6186. Ultrasound Software Development Kit (SDK)                      Version 2.10
  6187. ___________________________________________________________________________
  6188.  
  6189.                         Appendix B - Volume Control
  6190.  
  6191. Here are the volume ramp control bit definitions:
  6192.  
  6193.    =================================
  6194.    | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  6195.    =================================
  6196.      |   |   |   |   |   |   |   |
  6197.      |   |   |   |   |   |   |   +---- Reserved
  6198.      |   |   |   |   |   |   +-------- Reserved
  6199.      |   |   |   |   |   +------------ Reserved
  6200.      |   |   |   |   +---------------- loop enable (0=no loop, 1=loop)
  6201.      |   |   |   +-------------------- bi-direction. loop (1=enable)
  6202.      |   |   +------------------------ Enable volume ramp IRQ
  6203.      |   +---------------------------- Reserved
  6204.      +-------------------------------- Reserved
  6205.  
  6206. The bits that should be set by the application to get a particular type  of
  6207. volume ramp. The completed value should be supplied to UltraRampVolume  and
  6208. UltraRampLinearVolume. If volume interrupts are enabled, make sure that you
  6209. have set up a volume interrupt  handler (see UltraVolumeHandler). This  can
  6210. be used to create your own multi-point volume envelopes.
  6211.  
  6212. Bi-directional looping can be used to create a tremelo effect.
  6213.  
  6214.  
  6215.  
  6216.  
  6217.  
  6218.  
  6219.  
  6220.  
  6221.  
  6222.  
  6223.  
  6224.  
  6225.  
  6226.  
  6227.  
  6228.  
  6229.  
  6230.  
  6231.  
  6232.  
  6233.  
  6234.  
  6235.  
  6236.  
  6237.  
  6238.  
  6239.  
  6240.  
  6241.  
  6242.  
  6243.  
  6244. ___________________________________________________________________________
  6245.                                                                          96
  6246.  
  6247.  
  6248.  
  6249. Ultrasound Software Development Kit (SDK)                      Version 2.10
  6250. ___________________________________________________________________________
  6251.  
  6252.                         Appendix C - Voice Control
  6253.  
  6254. Here are the voice control bit definitions:
  6255.  
  6256.    =================================
  6257.    | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  6258.    =================================
  6259.      |   |   |   |   |   |   |   |
  6260.      |   |   |   |   |   |   |   +---- Rollover when hit ending addr
  6261.      |   |   |   |   |   |   +-------- Reserved
  6262.      |   |   |   |   |   +------------ data type (0=8 bit 1=16 bit)
  6263.      |   |   |   |   +---------------- loop enable (0=no loop, 1=loop)
  6264.      |   |   |   +-------------------- bi-direction. loop (1=enable)
  6265.      |   |   +------------------------ Enable wavetable IRQ
  6266.      |   +---------------------------- Direction (0=inc, 1=dec)
  6267.      +-------------------------------- Reserved
  6268.  
  6269. The UltraSound is capable of playing  back 8 or 16  bit data. (It can  only
  6270. record 8 bit). Stereo is handled by using 2 voices. It can loop on the data
  6271. in either a uni-directional or bi-directional mode. If you have asked  that
  6272. a particular voice generate a wavetable  interrupt when it hits the end  of
  6273. the data  (or  loop point,  if  looping is  specified),  be sure  you  have
  6274. specified a  wavetable interrupt  hander (UltraWaveHander).  The mode  bits
  6275. would be constructed  and passed to  UltraStartVoice and  UltraSetLoopMode.
  6276. The rollover bit  is used  to tell the  software to  program the  hardware:
  6277. generate an interrupt when the voice  hits the end address, but don't  stop
  6278. playing the voice (or loop if looping  is enabled). This allows a voice  to
  6279. continue to play but gives the  software a 'marker point' in the  playback.
  6280. This can be very powerfull to  allow a seamless playback. The hardware  bit
  6281. for turning rollover on is acutally in the voice's volume control  register
  6282. (there were no spare bits in the  voice control register). One of the  bits
  6283. is shared to tell the toolkit software to enable the rollover in the volume
  6284. control register.
  6285.  
  6286.  
  6287.  
  6288.  
  6289.  
  6290.  
  6291.  
  6292.  
  6293.  
  6294.  
  6295.  
  6296.  
  6297.  
  6298.  
  6299.  
  6300.  
  6301.  
  6302.  
  6303.  
  6304.  
  6305.  
  6306.  
  6307. ___________________________________________________________________________
  6308.                                                                          97
  6309.  
  6310.  
  6311.  
  6312. Ultrasound Software Development Kit (SDK)                      Version 2.10
  6313. ___________________________________________________________________________
  6314.  
  6315.                          Appendix D - DMA Control
  6316.  
  6317. Here are the dma to/from DRAM control bit definitions:
  6318.  
  6319.    =================================
  6320.    | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  6321.    =================================
  6322.      |   |   |   |   |   |   |   |
  6323.      |   |   |   |   |   |   |   +---- Reserved
  6324.      |   |   |   |   |   |   +-------- 0=write,1=Read
  6325.      |   |   |   |   |   +------------ Reserved
  6326.      |   |   |   |   +---------------- Reserved
  6327.      |   |   |   +-------------------- Reserved
  6328.      |   |   +------------------------ Reserved
  6329.      |   +---------------------------- Data size (0=8 bit, 1=16 bit)
  6330.      +-------------------------------- (1=convert to 2's comp.)
  6331.  
  6332. Note:   The UltraSound  DRAM  location MUST  be  on a  32  byte  boundary.
  6333.         UltraMemAlloc enforces this stipulation.
  6334.  
  6335. You define the  byte to be  passed to UltraUpload  and UltraDownload  using
  6336. these bits. To DMA the data out of DRAM, use UltraUpload.  To send data  to
  6337. the DRAM, use UltraDownload. Be sure to specify the sample size and whether
  6338. or not the data is in two's  compliment form. The UltraSound can only  play
  6339. data back that  is in two's  compliment form. If  your sample  is in  one's
  6340. compliment form,  turn on  bit 7  when specifying  the mode  when you  call
  6341. UltraDownload - the data  will be translated to  two's compliment as it  is
  6342. being DMA'ed.
  6343.  
  6344. Note:   If you are poking data  into DRAM, you MUST  put the data in  twos
  6345.         compliment yourself. This is accomplished by exclusive  or-ing the
  6346.         high bit with a 1.
  6347.  
  6348.  
  6349.  
  6350.  
  6351.  
  6352.  
  6353.  
  6354.  
  6355.  
  6356.  
  6357.  
  6358.  
  6359.  
  6360.  
  6361.  
  6362.  
  6363.  
  6364.  
  6365.  
  6366.  
  6367.  
  6368.  
  6369.  
  6370. ___________________________________________________________________________
  6371.                                                                          98
  6372.  
  6373.  
  6374.  
  6375. Ultrasound Software Development Kit (SDK)                      Version 2.10
  6376. ___________________________________________________________________________
  6377.  
  6378.                       Appendix E - Recording Control
  6379.  
  6380. Here are the recording control bit definitions:
  6381.  
  6382.    =================================
  6383.    | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  6384.    =================================
  6385.      |   |   |   |   |   |   |   |
  6386.      |   |   |   |   |   |   |   +---- Reserved
  6387.      |   |   |   |   |   |   +-------- mode (0=mono,1=stereo)
  6388.      |   |   |   |   |   +------------ Reserved
  6389.      |   |   |   |   +---------------- Reserved
  6390.      |   |   |   +-------------------- Reserved
  6391.      |   |   +------------------------ Reserved
  6392.      |   +---------------------------- Reserved
  6393.      +-------------------------------- (1=Convert to 2's comp.)
  6394.  
  6395.  
  6396.  
  6397.  
  6398.  
  6399.  
  6400.  
  6401.  
  6402.  
  6403.  
  6404.  
  6405.  
  6406.  
  6407.  
  6408.  
  6409.  
  6410.  
  6411.  
  6412.  
  6413.  
  6414.  
  6415.  
  6416.  
  6417.  
  6418.  
  6419.  
  6420.  
  6421.  
  6422.  
  6423.  
  6424.  
  6425.  
  6426.  
  6427.  
  6428.  
  6429.  
  6430.  
  6431.  
  6432.  
  6433. ___________________________________________________________________________
  6434.                                                                          99
  6435.  
  6436.  
  6437.  
  6438. Ultrasound Software Development Kit (SDK)                      Version 2.10
  6439. ___________________________________________________________________________
  6440.  
  6441.                          Appendix F - Patch Files
  6442.  
  6443. This appendix contains  information about the  the patch file  format.   It
  6444. assumes the reader is familiar with wave table synthesis, music, sound,
  6445. and the GF1 ASIC chip that is the heart of the UltraSound audio card.
  6446.  
  6447. The UltraSound patch file is a collection of data structures and sound data
  6448. in the following format:
  6449.  
  6450.     patch header (# instruments)
  6451.         instrument header 1 (#layers)
  6452.             layer 1 header (# waves)
  6453.              wave 1 header
  6454.              wave 1 data
  6455.                 wave 2 header
  6456.                 wave 2 data
  6457.                 ...
  6458.                 wave n header
  6459.                 wave n data
  6460.             layer 2 header (# waves)
  6461.                 wave 1 header
  6462.                 wave 1 data
  6463.                 wave 2 header
  6464.                 wave 2 data
  6465.                 ...
  6466.                 wave n header
  6467.                 wave n data
  6468.         instrument header 2 (#layers)
  6469.     etc.
  6470.  
  6471. All of the Advanced Gravis UltraSound patches contain one instrument at the
  6472. current time.  Except for the main patch header, each of the headers has  a
  6473. size field which can be used to seek past unwanted data.  For example, if a
  6474. patch has two instruments  and you want to  skip the first instrument,  you
  6475. would read  the  first instrument  header,  and then  skip  INSTRUMENT_SIZE
  6476. bytes.  What follows is the patch header definitions given in C and Pascal.
  6477. After the definitions, a field-by-field breakdown of the headers is given.
  6478.  
  6479. ======
  6480.   C:
  6481. ======
  6482.  
  6483. #define ENVELOPES                       6
  6484. #define HEADER_SIZE                     12
  6485. #define ID_SIZE                         10
  6486. #define DESC_SIZE                       60
  6487. #define RESERVED_SIZE                   40
  6488. #define PATCH_HEADER_RESERVED_SIZE      36
  6489. #define LAYER_RESERVED_SIZE             40
  6490. #define PATCH_DATA_RESERVED_SIZE        36
  6491. #define GF1_HEADER_TEXT                 "GF1PATCH110"
  6492. #define MAX_LAYERS                      4
  6493. #define INST_NAME_SIZE                  16
  6494.  
  6495.  
  6496. ___________________________________________________________________________
  6497.                                                                         100
  6498.  
  6499.  
  6500.  
  6501. Ultrasound Software Development Kit (SDK)                      Version 2.10
  6502. ___________________________________________________________________________
  6503.  
  6504. typedef struct
  6505. {
  6506.    char             header[ HEADER_SIZE ];
  6507.    char             gravis_id[ ID_SIZE ];   /* Id = "ID#000002" */
  6508.    char             description[ DESC_SIZE ];
  6509.    unsigned char    instruments;
  6510.    char             voices;
  6511.    char             channels;
  6512.    unsigned int     wave_forms;
  6513.    unsigned int     master_volume;
  6514.    unsigned long    data_size;
  6515.    char             reserved[ PATCH_HEADER_RESERVED_SIZE ];
  6516. } PATCHHEADER;
  6517.  
  6518. typedef struct
  6519. {
  6520.    unsigned int     instrument;
  6521.    char             instrument_name[ 16 ];
  6522.    long             instrument_size;
  6523.    char             layers;
  6524.    char             reserved[ RESERVED_SIZE ];
  6525. } INSTRUMENTDATA;
  6526.  
  6527. typedef struct
  6528. {
  6529.    char             layer_duplicate;
  6530.    char             layer;
  6531.    long             layer_size;
  6532.    char             samples;
  6533.    char             reserved[ LAYER_RESERVED_SIZE ];
  6534. } LAYERDATA;
  6535.  
  6536.  
  6537.  
  6538. ... continued on the next page ...
  6539.  
  6540.  
  6541.  
  6542.  
  6543.  
  6544.  
  6545.  
  6546.  
  6547.  
  6548.  
  6549.  
  6550.  
  6551.  
  6552.  
  6553.  
  6554.  
  6555.  
  6556.  
  6557.  
  6558.  
  6559. ___________________________________________________________________________
  6560.                                                                         101
  6561.  
  6562.  
  6563.  
  6564. Ultrasound Software Development Kit (SDK)                      Version 2.10
  6565. ___________________________________________________________________________
  6566.  
  6567. typedef struct
  6568. {
  6569.    char             wave_name[7];
  6570.  
  6571.    unsigned char    fractions;
  6572.    long             wave_size;
  6573.    long             start_loop;
  6574.    long             end_loop;
  6575.  
  6576.    unsigned int     sample_rate;
  6577.    long             low_frequency;
  6578.    long             high_frequency;
  6579.    long             root_frequency;
  6580.    int              tune;
  6581.  
  6582.    unsigned char    balance;
  6583.  
  6584.    unsigned char    envelope_rate[ ENVELOPES ];
  6585.    unsigned char    envelope_offset[ ENVELOPES ];
  6586.  
  6587.    unsigned char    tremolo_sweep;
  6588.    unsigned char    tremolo_rate;
  6589.    unsigned char    tremolo_depth;
  6590.  
  6591.    unsigned char    vibrato_sweep;
  6592.    unsigned char    vibrato_rate;
  6593.    unsigned char    vibrato_depth;
  6594.  
  6595.    /* bit 0 = 8 or 16 bit wave data. */
  6596.    /* bit 1 = Signed - Unsigned data. */
  6597.    /* bit 2 = looping enabled-1. */
  6598.    /* bit 3 = Set is bidirectional looping. */
  6599.    /* bit 4 = Set is looping backward. */
  6600.    /* bit 5 = Turn sustaining on. (Env. pts. 3)*/
  6601.    /* bit 6 = Enable envelopes - 1 */
  6602.    char             modes;
  6603.  
  6604.    int              scale_frequency;
  6605.    unsigned int     scale_factor;    /* from 0 to 2048 or 0 to 2 */
  6606.  
  6607.    char             reserved[ PATCH_DATA_RESERVED_SIZE ];
  6608. } PATCHDATA;
  6609.  
  6610.  
  6611.  
  6612. ...end of the C section.  Please see the next page for the PASCAL
  6613. section...
  6614.  
  6615.  
  6616.  
  6617.  
  6618.  
  6619.  
  6620.  
  6621.  
  6622. ___________________________________________________________________________
  6623.                                                                         102
  6624.  
  6625.  
  6626.  
  6627. Ultrasound Software Development Kit (SDK)                      Version 2.10
  6628. ___________________________________________________________________________
  6629.  
  6630. =========
  6631.  PASCAL:
  6632. =========
  6633.  
  6634. CONST
  6635.   ENVELOPES                  = 6;
  6636.   HEADER_SIZE                = 12;
  6637.   ID_SIZE                    = 10;
  6638.   DESC_SIZE                  = 60;
  6639.   RESERVED_SIZE              = 40;
  6640.   PATCH_HEADER_RESERVED_SIZE = 36;
  6641.   LAYER_RESERVED_SIZE        = 40;
  6642.   PATCH_DATA_RESERVED_SIZE   = 36;
  6643.   GF1_HEADER_TEXT            : ARRAY[1..12] OF CHAR = 'GF1PATCH110';
  6644.  
  6645. TYPE
  6646.   PATCHHEADER = RECORD
  6647.     Header        : ARRAY[1..HEADER_SIZE] OF CHAR;
  6648.     Gravis_ID     : ARRAY[1..ID_SIZE] OF CHAR;  { Id = 'ID#000002' }
  6649.     Description   : ARRAY[1..DESC_SIZE] OF CHAR;
  6650.     Instruments   : SHORTINT;
  6651.     Voices        : SHORTINT;
  6652.     Channels      : SHORTINT;
  6653.     Wave_Forms    : WORD;
  6654.     Master_Volume : WORD;
  6655.     Data_Size     : LONGINT;
  6656.     Reserved      : ARRAY[1..PATCH_HEADER_RESERVED_SIZE] OF BYTE;
  6657.    END;
  6658.  
  6659.   INSTRUMENTDATA = RECORD
  6660.     Instrument      : WORD;
  6661.     Instrument_Name : ARRAY[1..16] OF CHAR;
  6662.     Instrument_Size : LONGINT;
  6663.     Layers          : SHORTINT;
  6664.     Reserved        : ARRAY[1..RESERVED_SIZE] OF BYTE;
  6665.    END;
  6666.  
  6667.   LAYERDATA = RECORD
  6668.     Layer_Duplicate : SHORTINT;
  6669.     Layer           : SHORTINT;
  6670.     Layer_Size      : LONGINT;
  6671.     Samples         : SHORTINT;
  6672.     Reserved        : ARRAY[1..RESERVED_SIZE] OF BYTE;
  6673.    END;
  6674.  
  6675.  
  6676. ...continued on the next page...
  6677.  
  6678.  
  6679.  
  6680.  
  6681.  
  6682.  
  6683.  
  6684.  
  6685. ___________________________________________________________________________
  6686.                                                                         103
  6687.  
  6688.  
  6689.  
  6690. Ultrasound Software Development Kit (SDK)                      Version 2.10
  6691. ___________________________________________________________________________
  6692.  
  6693.   PATCHDATA = RECORD
  6694.     Wave_Name       : ARRAY[1..7] OF CHAR;
  6695.     Fractions       : BYTE;
  6696.     Wave_Size       : LONGINT;
  6697.     Start_Loop      : LONGINT;
  6698.     End_Loop        : LONGINT;
  6699.     Sample_Rate     : WORD;
  6700.     Low_Frequency   : LONGINT;
  6701.     High_Frequency  : LONGINT;
  6702.     Root_Frequency  : LONGINT;
  6703.     Tune            : INTEGER;
  6704.     Balance         : BYTE;
  6705.     Envelope_Rate   : ARRAY[1..ENVELOPES] OF BYTE;
  6706.     Envelope_Offset : ARRAY[1..ENVELOPES] OF BYTE;
  6707.     Tremolo_Sweep   : BYTE;
  6708.     Tremolo_Rate    : BYTE;
  6709.     Tremolo_Depth   : BYTE;
  6710.     Vibrato_Sweep   : BYTE;
  6711.     Vibrato_Rate    : BYTE;
  6712.     Vibrato_Depth   : BYTE;
  6713.  
  6714.     { bit 0 = 8 or 16 bit wave data.            }
  6715.     { bit 1 = Signed - Unsigned data.           }
  6716.     { bit 2 = looping enabled-1.                }
  6717.     { bit 3 = Set is bidirectional looping.     }
  6718.     { bit 4 = Set is looping backward.          }
  6719.     { bit 5 = Turn sustaining on. (Env. pts. 3) }
  6720.     { bit 6 = Enable envelopes - 1              }
  6721.     Modes           : SHORTINT;
  6722.  
  6723.     Scale_Frequency : INTEGER;
  6724.     Scale_Factor    : WORD; { From 0 to 2048 or 0 to 2 }
  6725.     Reserved        : ARRAY[1..PATCH_DATA_RESERVED_SIZE] OF BYTE;
  6726.    END;
  6727.  
  6728.  
  6729. File Header
  6730. _________________________________
  6731.  
  6732. 'Header'
  6733.      The header field should contain the  text "GF1PATCH110."  The first  8
  6734.      bytes will always be GF1PATCH.   The next three bytes are the  version
  6735.      number of the patch  format.  As  fields are added  to the patch,  the
  6736.      number will  be  incremented.   All  of  the  UltraSound  patches  are
  6737.      currently at version  110.   The older  100 patches  are obsolete  and
  6738.      should no longer be in use.
  6739.  
  6740. 'Description'
  6741.      This description field is usually for copyright information.
  6742.  
  6743. 'Instruments'
  6744.      The number of  instruments in the  patch.  All  of the gravis  patches
  6745.      contain only one instrument.
  6746.  
  6747.  
  6748. ___________________________________________________________________________
  6749.                                                                         104
  6750.  
  6751.  
  6752.  
  6753. Ultrasound Software Development Kit (SDK)                      Version 2.10
  6754. ___________________________________________________________________________
  6755.  
  6756. 'Voices'
  6757.      The GF1 synth  can update  14 voices  at 44.1Khz.   As  the number  of
  6758.      voices increases, the  actual output rate  of each  voice drops.  This
  6759.      field should contain the number of voices that were used when creating
  6760.      the patch. This field could be used by  a MIDI engine to try and  make
  6761.      the patch sound the  same regardless of the  number of active  voices.
  6762.      Currently this feature is not implemented in the gravis MIDI engine.
  6763.  
  6764. 'Channels'
  6765.      This field is unused.  Only mono data  can be played out a voice  with
  6766.      the GF1.
  6767.  
  6768. 'Wave_Forms'
  6769.      The total number of  waveforms in the  patch.  This  field is used  by
  6770.      programs which need to preallocate space for wave form headers  before
  6771.      the patch is loaded.
  6772.  
  6773. 'Master_Volume'
  6774.      This field is currently unused.
  6775.  
  6776. 'Data_Size'
  6777.      The size of the  patch data after it  is loaded into  GF1 dram.   This
  6778.      number includes the space needed to align each of the waveforms on  32
  6779.      byte boundaries.    If  you patch  loader  maintains  linked  list  of
  6780.      waveforms in dram, and you need to use an extra 32 bytes per waveform,
  6781.      then you can use  the wave_forms field to  figure out how much  memory
  6782.      you will need to load the patch.  i.e.  data_size + (32 * wave_forms).
  6783.  
  6784.  
  6785.  
  6786. Instrument Header
  6787. _________________________________
  6788.  
  6789. 'Instrument'
  6790.      This field is currently unused.
  6791.  
  6792. 'Instrument_Name'
  6793.      This field is currently unused.
  6794.  
  6795. 'Instrument_Size'
  6796.      The size of the instrument.  The number  of bytes to skip in order  to
  6797.      read the next instrument header.
  6798.  
  6799. 'Layers'
  6800.      The number of layers in this instrument.  Multiple layers are  usually
  6801.      used in patches where  more than one sound  is required with a  single
  6802.      MIDI event  (note on).   For  example, a  piano would  could have  two
  6803.      layers. The first would be the actual tone from the hammer hitting the
  6804.      strings, and the second would be  the (thunk) of the key being  struck
  6805.      and all of  the mechanisms moving  inside the piano.   The  mechanisms
  6806.      would probably be frequency independant,  and also independant of  the
  6807.      length of the tone.
  6808.  
  6809.  
  6810.  
  6811. ___________________________________________________________________________
  6812.                                                                         105
  6813.  
  6814.  
  6815.  
  6816. Ultrasound Software Development Kit (SDK)                      Version 2.10
  6817. ___________________________________________________________________________
  6818.  
  6819. Layer Header
  6820. __________________________
  6821.  
  6822. 'Layer_Duplicate'
  6823.      Currently unused.  If the layer duplicate  is nonzero, then this layer
  6824.      should use the  data from the  previous layer. Only  the headers  will
  6825.      follow.
  6826.  
  6827. 'Layer'
  6828.      The current layer number for this instrument
  6829.  
  6830. 'Layer_Size'
  6831.      The size of this layer.   Can be used to seek  past this layer in  the
  6832.      file.
  6833.  
  6834. 'Samples'
  6835.      The number  of waveforms  in this  layer.   This field  is ignored  if
  6836.      layer_duplicate is true.
  6837.  
  6838.  
  6839.  
  6840. Wave Header
  6841. _________________________________
  6842.  
  6843. 'Wave_Name'
  6844.      This field is currently unused
  6845.  
  6846. 'Fractions'
  6847.      The start_loop and end_loop are the integer portions of the  wavetable
  6848.      address.  The GF1 can interpolate between sample points and  therefore
  6849.      meore resolution than just  the integer address is  needed.  The  most
  6850.      significant four bits are the  fractional address for the  start_loop,
  6851.      and the least significant four bits are the fractional address for the
  6852.      end_loop.
  6853.  
  6854. 'Wave_Size'
  6855.      The number  of bytes  of wave  table data  that follows  -- not  #  of
  6856.      samples.
  6857.  
  6858. 'Start_Loop'
  6859.      The integer  portion of  the starting  loop  address relative  to  the
  6860.      beginning of the wave.  This address is the relative number of  bytes,
  6861.      and not the number of samples.
  6862.  
  6863. 'End_Loop'
  6864.      The integer  portion  of  the ending  loop  address  relative  to  the
  6865.      beginning of the wave.  This address is the relative number of  bytes,
  6866.      and not the number of samples.
  6867.  
  6868. 'Sample_Rate'
  6869.      This is the  sample rate of  the recorded data.   This  number is  not
  6870.      related to the actual pitch of the recorded tone.
  6871.  
  6872.  
  6873.  
  6874. ___________________________________________________________________________
  6875.                                                                         106
  6876.  
  6877.  
  6878.  
  6879. Ultrasound Software Development Kit (SDK)                      Version 2.10
  6880. ___________________________________________________________________________
  6881.  
  6882. 'Low_Frequency'
  6883.      Each wave  covers a  specific frequency  range.   This is  the  lowest
  6884.      frequency that this wave can be used to play.  This field is scaled be
  6885.      1000 for accuracy.
  6886.  
  6887. 'High_Frequency'
  6888.      Each wave covers  a specific  frequency range.   This  is the  highest
  6889.      frequency that this wave can be used to play.  This field is scaled by
  6890.      1000 for accuracy.  If there is another wave adjacent to this one  and
  6891.      its range overlaps this range, then  the next waveform will always  be
  6892.      chosen.
  6893.  
  6894. 'Root_Frequency'
  6895.      If this wave  is played back  at the original  sample_rate, then  this
  6896.      number should  be the  pitch of  the  original tone.   This  field  is
  6897.      modified to tune the wave to a particular pitch.  This field is scaled
  6898.      by 1000 for accuracy.
  6899.  
  6900. 'Tune'
  6901.      This field is unused.   Tuning is accomplished  by modifying the  root
  6902.      frequency.
  6903.  
  6904. 'Balance'
  6905.      0 is 100% to the right, and 15 is 100% to the left.  As the balance is
  6906.      shifted from left to right, the total output power of both channels is
  6907.      constant.
  6908.  
  6909. 'Envelope_Rate'
  6910.      An array of 6 rates to  implement a 6-point envelope. The first  three
  6911.      rates can be used for attack and decay.   If the sustain flag is  set,
  6912.      than the third  envelope point  will be  the sustain  point. The  last
  6913.      three envelope  points are  for the  release, and  an optional  "echo"
  6914.      effect.  If the last envelope point is left at an audible level,  then
  6915.      a sampled release can  heard after the last  envelope point. The  rate
  6916.      values are sent directly to the GF1 hardware, and are described in the
  6917.      volume ramping section.
  6918.  
  6919. 'Envelope_Offset'
  6920.      An array of 6 offsets to implement a 6-point envelope. The first three
  6921.      offsets can be used for attack and decay.  If the sustain flag is set,
  6922.      than the third  envelope point will  be the sustain  point.  The  last
  6923.      three envelope  points are  for the  release, and  an optional  "echo"
  6924.      effect.  If the last envelope point is left at an audible level,  then
  6925.      a sampled release can heard after the last envelope point.  The offset
  6926.      values are sent directly to the GF1 hardware, and are described in the
  6927.      volume ramping section.
  6928.  
  6929. 'Tremolo_Sweep'
  6930.      Not implemented.  Tremolo starts automatically when the note sustains.
  6931.      This will be  changed in  future software  to gradually  sweep in  the
  6932.      tremolo depth from 0 at the rate of tremolo_sweep / 45 seconds.
  6933.  
  6934.  
  6935.  
  6936.  
  6937. ___________________________________________________________________________
  6938.                                                                         107
  6939.  
  6940.  
  6941.  
  6942. Ultrasound Software Development Kit (SDK)                      Version 2.10
  6943. ___________________________________________________________________________
  6944.  
  6945. 'Tremolo_Rate'
  6946.      The rate of amplitude modulation.  0 is 0.05 Hz,  and 255 is 6 Hz.   A
  6947.      complete table is listed below.
  6948.  
  6949. 'Tremolo_Depth'
  6950.      0 means  turn tremolo  off.   255  provides a  16  dB modulation.    A
  6951.      complete table is listed below.
  6952.  
  6953. 'Vibrato_Sweep'
  6954.      Gradually  sweep  in  the  vibrato  depth  from  0  at  the  rate   of
  6955.      vibrato_sweep / 45 seconds.
  6956.  
  6957. 'Vibrato_Rate'
  6958.      The rate of frequency modulation.  0 is 0.05 Hz, and 255 is 6 Hz.
  6959.  
  6960. 'Vibrato_Depth'
  6961.      0 means turn vibrato off.  255 is a one octave modulation.
  6962.  
  6963. 'Modes'
  6964.      A set of bit fields describing modes and data type:
  6965.      BIT 0- 16 bit data
  6966.      BIT 1- unsigned data
  6967.      BIT 2- looping enabled
  6968.      BIT 3- bidirectional loop
  6969.      BIT 4- play patch backwards.   start at end address,  loop backwards,
  6970.             and then end at beginning address.
  6971.      BIT 5- sustain - enveloping  stops at third  envelope point.   a note
  6972.             off will continue enveloping.
  6973.      BIT 6- currently means enveloping enabled.   All gravis  patches have
  6974.             this bit set.  This field will be modified  in the near future
  6975.             to implement a sampled release  at note off instead  of at the
  6976.             last envelope point.   If this bit  is on, the  sample release
  6977.             occurs after the last envelope point.  If this bit is off, the
  6978.             sampled release occurs at the note off.
  6979.      BIT 7- fast release.  The last three envelope points are ignored.
  6980.  
  6981. 'Scale_Frequency'
  6982.      Keyboard frequency scaling.  Normally, MIDI note 64 plays a middle  C.
  6983.      A 65 plays a C#.  frequency  scaling changes the distance in pitch  of
  6984.      each MIDI note.   The scale_frequency is the MIDI note number which is
  6985.      the pivot point for scaling.  If scale_frequency is 64, then MIDI note
  6986.      64 will sound like a C4 regardless of scale factor.
  6987.  
  6988. 'Scale_Factor'
  6989.      1024 means normal scaling.  Each MIDI note is  one semitone away  from
  6990.      its neighbor.  512 would be 1/2 semitone apart.  2048 is two semitones
  6991.      apart.
  6992.  
  6993.  
  6994.  
  6995.  
  6996.  
  6997.  
  6998.  
  6999.  
  7000. ___________________________________________________________________________
  7001.                                                                         108
  7002.  
  7003.  
  7004.  
  7005. Ultrasound Software Development Kit (SDK)                      Version 2.10
  7006. ___________________________________________________________________________
  7007.  
  7008.                         Appendix G - 3D File Header
  7009.  
  7010. Here is a definition for the data found in Focal-Point 3D files. All .F3D
  7011. files will have this format.  Both C and PASCAL versions of the definition
  7012. are listed below.
  7013.  
  7014. ======
  7015.   C:
  7016. ======
  7017.  
  7018. /* Bit definitions for tracks that are in a 3D file ... */
  7019. #define FRONT_TRACK      0x01
  7020. #define RIGHT_TRACK      0x02
  7021. #define REAR_TRACK       0x04
  7022. #define LEFT_TRACK       0x08
  7023. #define ABOVE_TRACK      0x10
  7024. #define BELOW_TRACK      0x20
  7025.  
  7026. #define FBLOCK_3D        0x01    /* File data is blocked */
  7027. #define F16BIT_3D        0x02    /* 16 bit data */
  7028. #define FTWOS_CMP_3D     0x04    /* sound is in twos complement form */
  7029. #define FLOOPED_3D       0x08    /* sound is looped , not one shot*/
  7030. #define FBI_LOOP_3D      0x10    /* sound is bi-directional */
  7031. #define F3D_TYPE         0x60    /* Type of 3D sound */
  7032.  
  7033. /* types (F3D_TYPE) of 3D sound (only binaural currently supported) */
  7034. #define F_BINAURAL       0x20    /* Binaural representation */
  7035. #define F_SURROUND       0x40    /* Surround sound (???) */
  7036. #define F_QSOUND         0x60    /* Q sound (???) */
  7037.  
  7038. /* the following structure is exactly 256 bytes long ... */
  7039. typedef struct {
  7040.    char id[10];                /* 3D FILE tag */
  7041.    int major;                  /* major version # */
  7042.    int minor;                  /* minor version # */
  7043.    char description[80];
  7044.    unsigned int type;          /* See above .... */
  7045.    int tracks;                 /* tracks included in this file ... */
  7046.    int reserve1[24];           /* for expansion */
  7047.    int maxvol;                 /* volume can range from 0 to maxvol */
  7048.    int reserve2[10];           /* for expansion */
  7049.    unsigned long blocksize;    /* # of bytes in block data */
  7050.    unsigned long loop_offset;  /* byte offset to where loop begins */
  7051.    unsigned long reserve3[9];  /* for expansion */
  7052.    unsigned long frequency;    /* initial playback frequency */
  7053.    unsigned long reserve4[10]; /* for expansion */
  7054. } FILEHDR_3D;
  7055.  
  7056.  
  7057. ...end of the C section.  Please see the next page for the PASCAL
  7058. section...
  7059.  
  7060.  
  7061.  
  7062.  
  7063. ___________________________________________________________________________
  7064.                                                                         109
  7065.  
  7066.  
  7067.  
  7068. Ultrasound Software Development Kit (SDK)                      Version 2.10
  7069. ___________________________________________________________________________
  7070.  
  7071. ========
  7072.  PASCAL
  7073. ========
  7074.  
  7075. CONST
  7076.   { Bit definitions FOR tracks that are in a 3D FILE ... }
  7077.   FRONT_TRACK  = $01;
  7078.   RIGHT_TRACK  = $02;
  7079.   REAR_TRACK   = $04;
  7080.   LEFT_TRACK   = $08;
  7081.   ABOVE_TRACK  = $10;
  7082.   BELOW_TRACK  = $20;
  7083.  
  7084.   FBLOCK_3D    = $01; { FILE data is blocked, NOT interleaved }
  7085.   F16BIT_3D    = $02; { 16 bit data }
  7086.   FTWOS_CMP_3D = $04; { sound is in twos complement form }
  7087.   FLOOPED_3D   = $08; { sound is looped , NOT one shot }
  7088.   FBI_LOOP_3D  = $10; { sound is bi-directional }
  7089.   F3D_TYPE     = $60; { TYPE OF 3D sound }
  7090.  
  7091.   { types (F3D_TYPE) OF 3D sound (only binaural currently supported) }
  7092.   F_BINAURAL   = $20; { Binaural representation }
  7093.   F_SURROUND   = $40; { Surround sound (???) }
  7094.   F_QSOUND     = $60; { Q sound (???) }
  7095.  
  7096. TYPE
  7097.   FILEHDR_3D = RECORD
  7098.     ID          : ARRAY[0..9] OF CHAR;     { 3D FILE tag }
  7099.     Major       : INTEGER;                 { Major version # }
  7100.     Minor       : INTEGER;                 { Minor version # }
  7101.     Description : ARRAY[0..79] OF CHAR;
  7102.     SType       : WORD;                    { See above }
  7103.     Tracks      : INTEGER;                 { Tracks included }
  7104.     Reserve1    : ARRAY[0..23] OF INTEGER; { for expansion }
  7105.     MaxVol      : INTEGER;                 { volume range 0-maxvol }
  7106.     Reserve2    : ARRAY[0..9] OF INTEGER;  { for expansion }
  7107.     BlockSize   : LONGINT;                 { # of bytes in block data }
  7108.     Loop_Offset : LONGINT;                 { byte offset of loop begin}
  7109.     Reserve3    : ARRAY[0..8] OF LONGINT;  { for expansion }
  7110.     Frequency   : LONGINT;                 { playback frequency }
  7111.     Reserve4    : ARRAY[0..9] OF LONGINT;  { for expansion }
  7112.    END;
  7113.   { the file header is exactly 256 bytes long }
  7114.  
  7115.  
  7116.  
  7117.  
  7118.  
  7119.  
  7120.  
  7121.  
  7122.  
  7123.  
  7124.  
  7125.  
  7126. ___________________________________________________________________________
  7127.                                                                         110
  7128.